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

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 (86) 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 +0 -3
  13. package/dist/commands/app/install.js +12 -21
  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 +9 -12
  17. package/dist/commands/app/push.js +57 -131
  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 +60 -39
  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 +131 -128
  26. package/dist/commands/create/frontend.d.ts +12 -0
  27. package/dist/commands/create/frontend.js +38 -0
  28. package/dist/commands/create/function.d.ts +2 -2
  29. package/dist/commands/create/function.js +2 -2
  30. package/dist/commands/create/notification.d.ts +2 -2
  31. package/dist/commands/create/notification.js +2 -2
  32. package/dist/commands/env.d.ts +12 -0
  33. package/dist/commands/env.js +31 -0
  34. package/dist/commands/login.js +7 -7
  35. package/dist/commands/logs.js +0 -3
  36. package/dist/commands/theme/dev.d.ts +21 -0
  37. package/dist/commands/theme/dev.js +164 -0
  38. package/dist/commands/theme/init.d.ts +9 -0
  39. package/dist/commands/theme/init.js +15 -0
  40. package/dist/commands/theme/pull.d.ts +20 -0
  41. package/dist/commands/theme/pull.js +65 -0
  42. package/dist/commands/theme/push.d.ts +19 -0
  43. package/dist/commands/theme/push.js +89 -0
  44. package/dist/create-app-command.d.ts +20 -0
  45. package/dist/create-app-command.js +253 -0
  46. package/dist/create-collection-command.d.ts +3 -3
  47. package/dist/create-collection-command.js +4 -4
  48. package/dist/{create-command.d.ts → create-config-command.d.ts} +1 -1
  49. package/dist/{create-command.js → create-config-command.js} +3 -5
  50. package/dist/env/local.d.ts +8 -0
  51. package/dist/env/local.js +7 -0
  52. package/dist/env/production.d.ts +8 -0
  53. package/dist/env/production.js +7 -0
  54. package/dist/env/review.d.ts +8 -0
  55. package/dist/env/review.js +7 -0
  56. package/dist/env/staging.d.ts +8 -0
  57. package/dist/env/staging.js +7 -0
  58. package/dist/lib/api.d.ts +1 -0
  59. package/dist/lib/api.js +39 -13
  60. package/dist/lib/app-config.d.ts +12 -5
  61. package/dist/lib/app-config.js +57 -21
  62. package/dist/lib/apps/app-config.d.ts +17 -3
  63. package/dist/lib/apps/app-config.js +194 -66
  64. package/dist/lib/apps/index.d.ts +92 -12
  65. package/dist/lib/apps/index.js +145 -47
  66. package/dist/lib/apps/paths.d.ts +14 -7
  67. package/dist/lib/apps/paths.js +73 -28
  68. package/dist/lib/config.d.ts +9 -2
  69. package/dist/lib/config.js +49 -1
  70. package/dist/lib/constants.d.ts +5 -0
  71. package/dist/lib/constants.js +23 -4
  72. package/dist/lib/create/content.d.ts +1 -1
  73. package/dist/lib/create/index.js +5 -1
  74. package/dist/lib/info.js +2 -2
  75. package/dist/lib/stores.d.ts +5 -3
  76. package/dist/lib/stores.js +7 -5
  77. package/dist/lib/style.d.ts +2 -0
  78. package/dist/lib/style.js +2 -0
  79. package/dist/push-app-command.d.ts +73 -0
  80. package/dist/push-app-command.js +754 -0
  81. package/dist/remote-app-command.d.ts +35 -9
  82. package/dist/remote-app-command.js +417 -159
  83. package/oclif.manifest.json +817 -71
  84. package/package.json +13 -1
  85. package/dist/commands/app/_pull.d.ts +0 -8
  86. package/dist/commands/app/_pull.js +0 -45
@@ -14,8 +14,8 @@ export declare abstract class AppCommand extends SwellCommand {
14
14
  static baseFlags: {
15
15
  'app-path': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
16
16
  };
17
- appConfig: any;
18
17
  appPath: string;
18
+ swellConfig: any;
19
19
  constructor(argv: string[], config: Config);
20
20
  init(): Promise<void>;
21
21
  protected initBaseFlags(): Promise<void>;
@@ -1,5 +1,6 @@
1
1
  import { Flags } from '@oclif/core';
2
- import { default as appConfig } from './lib/app-config.js';
2
+ import * as path from 'node:path';
3
+ import { default as swellConfig } from './lib/app-config.js';
3
4
  import { SwellCommand } from './swell-command.js';
4
5
  /**
5
6
  * A base class for Swell CLI commands that do not require an app to be saved
@@ -16,17 +17,17 @@ export class AppCommand extends SwellCommand {
16
17
  // needs to be in a ES2021 format: https://github.com/oclif/oclif/issues/1100
17
18
  static baseFlags = {
18
19
  'app-path': Flags.string({
19
- description: 'path to the app directory',
20
+ description: 'path to your app directory',
20
21
  }),
21
22
  };
22
- // local app configuration, what developers define
23
- appConfig;
24
23
  // the local path to the app directory
25
24
  appPath = '';
25
+ // local app configuration, what developers define
26
+ swellConfig;
26
27
  constructor(argv, config) {
27
28
  super(argv, config);
28
- this.appConfig = appConfig();
29
- this.appPath = this.appConfig.swDirPath;
29
+ this.swellConfig = swellConfig();
30
+ this.appPath = path.resolve(this.swellConfig.swDirPath);
30
31
  }
31
32
  async init() {
32
33
  await super.init();
@@ -38,8 +39,7 @@ export class AppCommand extends SwellCommand {
38
39
  klass.flags = { ...klass.flags, ...AppCommand.baseFlags };
39
40
  const { flags } = await this.parse(klass);
40
41
  // if the user passed an app path, use it: reload the app config
41
- this.appConfig = appConfig(flags['app-path']);
42
- this.appPath = this.appConfig.swDirPath;
43
- this.debug(`config path loaded: ${this.appConfig.path}`);
42
+ this.swellConfig = swellConfig(flags['app-path']);
43
+ this.appPath = path.resolve(this.swellConfig.swDirPath);
44
44
  }
45
45
  }
@@ -0,0 +1,16 @@
1
+ import { PushAppCommand } from '../../push-app-command.js';
2
+ export default class AppDev extends PushAppCommand {
3
+ static delayOrientation: boolean;
4
+ static examples: string[];
5
+ static flags: {
6
+ 'storefront-id': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
7
+ 'storefront-select': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
8
+ 'no-push': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
9
+ port: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
10
+ };
11
+ static orientation: {
12
+ env: string;
13
+ };
14
+ static summary: string;
15
+ run(): Promise<void>;
16
+ }
@@ -0,0 +1,28 @@
1
+ import { Flags } from '@oclif/core';
2
+ import { PushAppCommand } from '../../push-app-command.js';
3
+ import AppFrontendDev from './frontend/dev.js';
4
+ export default class AppDev extends PushAppCommand {
5
+ static delayOrientation = true;
6
+ static examples = [
7
+ 'swell app dev',
8
+ 'swell app dev --storefront-id <id>',
9
+ 'swell app dev --port 3000',
10
+ ];
11
+ static flags = {
12
+ ...AppFrontendDev.flags,
13
+ 'storefront-id': Flags.string({
14
+ description: 'for storefront apps, identify a storefront to preview and push theme files to',
15
+ }),
16
+ 'storefront-select': Flags.boolean({
17
+ default: false,
18
+ description: 'for storefront apps, prompt to select a storefront to preview',
19
+ }),
20
+ };
21
+ static orientation = {
22
+ env: 'test',
23
+ };
24
+ static summary = `Run an app in dev mode from your local machine.`;
25
+ async run() {
26
+ await this.config.runCommand('app:frontend:dev', this.argv);
27
+ }
28
+ }
@@ -0,0 +1,15 @@
1
+ import { PushAppCommand } from '../../../push-app-command.js';
2
+ export default class AppFrontendDeploy extends PushAppCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ force: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
7
+ 'storefront-id': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
8
+ 'storefront-select': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
9
+ };
10
+ static orientation: {
11
+ env: string;
12
+ };
13
+ static summary: string;
14
+ run(): Promise<void>;
15
+ }
@@ -0,0 +1,41 @@
1
+ import { Flags } from '@oclif/core';
2
+ import { PushAppCommand } from '../../../push-app-command.js';
3
+ export default class AppFrontendDeploy extends PushAppCommand {
4
+ static description = `Creates a new build using the relevant command depending on your frontend framework.
5
+ Once the build succeeds, this command will invoke Cloudflare Wrangler to upload
6
+ build assets using your own Cloudflare account. Once complete, Swell will update
7
+ the app's deployment URL and push the updated frontend files.`;
8
+ static examples = [
9
+ 'swell app frontend deploy',
10
+ 'swell app frontend deploy --force',
11
+ 'swell app frontend deploy --storefront-select',
12
+ 'swell app frontend deploy --storefront-id <id>',
13
+ ];
14
+ static flags = {
15
+ force: Flags.boolean({
16
+ description: 'force push and build all frontend files',
17
+ }),
18
+ 'storefront-id': Flags.string({
19
+ description: 'identify a storefront to preview deployment with',
20
+ }),
21
+ 'storefront-select': Flags.boolean({
22
+ default: false,
23
+ description: 'prompt to select a storefront to preview deployment with',
24
+ }),
25
+ };
26
+ static orientation = {
27
+ env: 'test',
28
+ };
29
+ static summary = `Push frontend files to your Swell app.`;
30
+ async run() {
31
+ const { flags } = await this.parse(AppFrontendDeploy);
32
+ const { force } = flags;
33
+ if (!(await this.ensureAppExists())) {
34
+ return;
35
+ }
36
+ if (this.app.type === 'storefront') {
37
+ await this.getStorefrontToPush(flags);
38
+ }
39
+ await this.deployAppFrontend(force);
40
+ }
41
+ }
@@ -0,0 +1,19 @@
1
+ import { FrontendProjectType } from '../../../lib/apps/index.js';
2
+ import { PushAppCommand } from '../../../push-app-command.js';
3
+ export default class AppFrontendDev extends PushAppCommand {
4
+ static examples: string[];
5
+ static flags: {
6
+ 'no-push': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
7
+ port: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
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
+ logAppLocalUrl(storeId: string, sessionId: string): void;
16
+ run(): Promise<void>;
17
+ startDevServer(projectType: FrontendProjectType, port?: number): Promise<void>;
18
+ updateLocalProxy(proxyUrl: string, spinner: any, storefrontId?: string): Promise<void>;
19
+ }
@@ -0,0 +1,108 @@
1
+ import { Flags } from '@oclif/core';
2
+ import getPort, { portNumbers } from 'get-port';
3
+ import ngrok from 'ngrok';
4
+ import ora from 'ora';
5
+ import { default as localConfig } from '../../../lib/config.js';
6
+ import style from '../../../lib/style.js';
7
+ import { PushAppCommand } from '../../../push-app-command.js';
8
+ const FALLBACK_PORT = 3000;
9
+ export default class AppFrontendDev extends PushAppCommand {
10
+ static examples = [
11
+ 'swell app frontend dev',
12
+ 'swell app frontend dev --no-push',
13
+ 'swell app frontend dev --port 3000',
14
+ 'swell app frontend dev --storefront-select',
15
+ 'swell app frontend dev --storefront-id <id>',
16
+ ];
17
+ static flags = {
18
+ 'no-push': Flags.boolean({
19
+ description: 'skip pushing app files initially',
20
+ }),
21
+ port: Flags.integer({
22
+ char: 'p',
23
+ description: 'override the default port to run the app locally',
24
+ }),
25
+ 'storefront-id': Flags.string({
26
+ description: 'identify a storefront to preview with and push theme files to',
27
+ }),
28
+ 'storefront-select': Flags.boolean({
29
+ default: false,
30
+ description: 'prompt to select a storefront to preview with',
31
+ }),
32
+ };
33
+ static orientation = {
34
+ env: 'test',
35
+ };
36
+ static summary = `Run a frontend app in dev mode from your local machine.`;
37
+ logAppLocalUrl(storeId, sessionId) {
38
+ const frontendAppRoute = this.app.type === 'storefront' && this.app.storefront?.external
39
+ ? `/${this.app.private_id}`
40
+ : '';
41
+ this.log(`View it at ${style.link(`${this.localFrontendUrl(storeId, sessionId)}${frontendAppRoute}`)}\n`);
42
+ }
43
+ async run() {
44
+ const { flags } = await this.parse(AppFrontendDev);
45
+ const { port } = flags;
46
+ const noPush = flags['no-push'];
47
+ if (!(await this.ensureAppExists(undefined, false))) {
48
+ return;
49
+ }
50
+ if (!noPush) {
51
+ await this.pushAppConfigs();
52
+ }
53
+ if (this.app.type === 'storefront') {
54
+ await this.getStorefrontToPush(flags);
55
+ this.logStorefrontConnected();
56
+ }
57
+ this.saveCurrentStorefront();
58
+ const projectType = this.getFrontendProjectType();
59
+ await this.startDevServer(projectType, port);
60
+ }
61
+ async startDevServer(projectType, port) {
62
+ const currentStore = localConfig.getDefaultStore();
63
+ const spinner = ora();
64
+ // Find an open port starting at 3000
65
+ const freePort = port ||
66
+ (await getPort({ port: portNumbers(3000, 3100) })) ||
67
+ FALLBACK_PORT;
68
+ this.log(`Starting ${projectType.name} dev server...\n`);
69
+ // Start ngrok proxy
70
+ const proxyUrl = await ngrok.connect({
71
+ addr: freePort,
72
+ region: 'us', // TODO: make it configurable
73
+ });
74
+ await this.updateLocalProxy(proxyUrl, spinner, this.storefront?.id);
75
+ return this.exec(projectType.devCommand.replace('${PORT}', String(freePort)), (string) => {
76
+ // Hide useless astro warning about image optimization
77
+ if (string.includes('The current configuration does not support image optimization')) {
78
+ return false;
79
+ }
80
+ // Hide useless astro warning about .dev.vars
81
+ if (string.includes('There is no `.dev.vars` file')) {
82
+ return false;
83
+ }
84
+ // Hide astro localhost URL/network as it can confuse the user
85
+ if (string.includes('┃ Local') || string.includes('┃ Network')) {
86
+ return false;
87
+ }
88
+ // Started, show app url (TODO for nextjs)
89
+ if (string.includes('watching for file changes')) {
90
+ spinner.succeed(`Started ${projectType.name} dev server on port ${freePort}.\n`);
91
+ const sessionId = localConfig.getSessionId(currentStore);
92
+ setTimeout(() => this.logAppLocalUrl(currentStore, sessionId), 100);
93
+ this.watchForChanges();
94
+ }
95
+ });
96
+ }
97
+ async updateLocalProxy(proxyUrl, spinner, storefrontId) {
98
+ const storefront = this.app.type === 'storefront' &&
99
+ (await this.getAppStorefront({ storefront_id: storefrontId }));
100
+ await this.handleRequestErrors(async () => this.api.put({ adminPath: `/client/apps/${this.app.id}/local-proxy` }, {
101
+ body: {
102
+ proxy_url: proxyUrl,
103
+ storefront_id: storefront?.id || null,
104
+ storefront_slug: storefront?.slug || null,
105
+ },
106
+ }), () => spinner.fail('Error starting local proxy'));
107
+ }
108
+ }
@@ -13,7 +13,6 @@ const FIELDS_TO_DISPLAY = [
13
13
  'published',
14
14
  'date_created',
15
15
  'date_updated',
16
- 'installed',
17
16
  'client',
18
17
  ];
19
18
  export default class AppInfo extends RemoteAppCommand {
@@ -46,25 +45,31 @@ it will output all versions of the app instead.`;
46
45
  async showAppInfo() {
47
46
  const spinner = ora();
48
47
  spinner.start('Retrieving app info...');
49
- this.app = await this.getAppWithConfig().catch((error) => {
50
- spinner.fail(`Error fetching app info:`);
51
- throw error;
52
- });
48
+ const app = await this.getAppWithConfig().catch(() => null);
49
+ this.app = app || this.swellConfig.store;
50
+ if (!this.app) {
51
+ spinner.fail('App not found');
52
+ return;
53
+ }
53
54
  if (spinner.isSpinning) {
54
55
  spinner.stop();
55
56
  }
56
57
  // we pull versions to make sure that what is displayed is the latest
57
- const versions = await this.getVersions();
58
+ const versions = app ? await this.getVersions() : [];
58
59
  // Output the app field information, e.g.:
59
60
  // Name: My App
60
61
  const fieldDefinitions = new FieldDefinitions(this.app, versions);
61
62
  for (const field of FIELDS_TO_DISPLAY) {
62
63
  const fieldDef = fieldDefinitions.getFieldDefinition(field);
63
- this.log(style.appConfigName(`${fieldDef.label}:`), fieldDef.value);
64
+ if (fieldDef.value) {
65
+ this.log(style.appConfigName(`${fieldDef.label}:`), fieldDef.value);
66
+ }
64
67
  }
65
68
  // dashboard url is built, not part of the app object
66
69
  // we display it at the end for better readability and simplicity
67
- this.log(style.appConfigName('Dashboard:'), style.link(this.dashboardUrl({}, this.app.client_id)));
70
+ if (this.app.client_id) {
71
+ this.log(style.appConfigName('Dashboard:'), style.link(this.dashboardUrl({}, this.app.client_id)));
72
+ }
68
73
  }
69
74
  async showVersions() {
70
75
  const spinner = ora();
@@ -81,7 +86,7 @@ it will output all versions of the app instead.`;
81
86
  spinner.succeed(`${this.app.name} app versions:\n`);
82
87
  const displayData = versions.map((appVersion) => [
83
88
  style.appConfigValue(appVersion.version),
84
- appVersion.notes,
89
+ appVersion.description,
85
90
  new Date(appVersion.date_created).toUTCString(),
86
91
  ]);
87
92
  this.log(table(displayData, {
@@ -0,0 +1,12 @@
1
+ import CreateApp from '../create/app.js';
2
+ export default class InitApp extends CreateApp {
3
+ static description: string;
4
+ static examples: {
5
+ command: string;
6
+ description: string;
7
+ }[];
8
+ static flags: {
9
+ yes: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
10
+ };
11
+ run(): Promise<void>;
12
+ }
@@ -0,0 +1,34 @@
1
+ import { Flags } from '@oclif/core';
2
+ import path from 'node:path';
3
+ import CreateApp from '../create/app.js';
4
+ export default class InitApp extends CreateApp {
5
+ static description = 'Initialize app swell.json in the current directory.';
6
+ static examples = [
7
+ {
8
+ command: 'swell app init',
9
+ description: 'Initialize app following command prompts.',
10
+ },
11
+ {
12
+ command: 'swell app init -y',
13
+ description: 'Initialize app and accept all default values.',
14
+ },
15
+ ];
16
+ static flags = {
17
+ yes: Flags.boolean({
18
+ char: 'y',
19
+ description: `accept all default values`,
20
+ }),
21
+ };
22
+ async run() {
23
+ const { flags } = await this.parse(InitApp);
24
+ const { yes: confirmYes } = flags;
25
+ const id = process.cwd().split(path.sep).pop() || 'Swell App';
26
+ await this.createSwellConfig({
27
+ allowOverwrite: false,
28
+ inputId: id,
29
+ inputType: this.appType,
30
+ inputYes: confirmYes,
31
+ nestedPath: false,
32
+ });
33
+ }
34
+ }
@@ -13,8 +13,5 @@ export default class AppInstall extends RemoteAppCommand {
13
13
  static summary: string;
14
14
  run(): Promise<void>;
15
15
  private confirmRemoveDevelopmentApp;
16
- private getInstalledApp;
17
- private installApp;
18
16
  private installConfirmationMessage;
19
- private updateApp;
20
17
  }
@@ -11,9 +11,9 @@ export default class AppInstall extends RemoteAppCommand {
11
11
 
12
12
  Without a store specified, install the app in the Live environment of the current store.`;
13
13
  static examples = [
14
- 'swell install',
15
- 'swell install -v 3.2.7',
16
- 'swell install -v 1.0.0 -s my-store-id',
14
+ 'swell app install',
15
+ 'swell app install -v 3.2.7',
16
+ 'swell app install -v 1.0.0 -s my-store-id',
17
17
  ];
18
18
  static flags = {
19
19
  env: Flags.string({
@@ -102,25 +102,28 @@ Without a store specified, install the app in the Live environment of the curren
102
102
  return;
103
103
  }
104
104
  const spinner = ora();
105
+ this.log();
105
106
  // install or update app depending on whether it's already installed
106
107
  let request;
107
108
  if (existingInstalledApp?.id) {
108
- spinner.start(`Updating${extraMessage}...`);
109
- request = async () => this.updateApp(versionToInstall);
109
+ spinner.start(`Updating${extraMessage}`);
110
+ request = async () => this.updateInstalledApp(versionToInstall, spinner);
110
111
  }
111
112
  else {
112
- spinner.start(`Installing${extraMessage}...`);
113
- request = async () => this.installApp(versionToInstall);
113
+ spinner.start(`Installing${extraMessage}`);
114
+ request = async () => this.installApp(versionToInstall, spinner);
114
115
  }
115
116
  const response = await this.handleRequestErrors(request, () => spinner.fail('Something went wrong.'));
116
117
  if (response?.errors) {
117
118
  spinner.fail(`Error installing app: ${JSON.stringify(response.errors)}`);
118
119
  }
119
- spinner.succeed(`Install complete. Manage app settings in your dashboard at ${style.link(this.dashboardUrl({ flags: { env: envToInstall } }, storeToInstall))}.`);
120
+ else {
121
+ spinner.succeed(`${existingInstalledApp?.id ? 'Update' : 'Install'} complete.\n`);
122
+ this.log(`Manage app settings in your dashboard at ${style.link(this.dashboardUrl({ flags: { env: envToInstall } }, storeToInstall))}.`);
123
+ }
120
124
  }
121
125
  async confirmRemoveDevelopmentApp(storeToInstall) {
122
126
  const existingSourcedApps = await this.api.get({ adminPath: `/client/apps` }, {
123
- // eslint-disable-next-line camelcase
124
127
  query: { source_id: this.app.id },
125
128
  });
126
129
  if (existingSourcedApps.results[0]?.id) {
@@ -150,15 +153,6 @@ Without a store specified, install the app in the Live environment of the curren
150
153
  }
151
154
  return true;
152
155
  }
153
- async getInstalledApp() {
154
- // check if app is already installed on store
155
- return this.api.get({ adminPath: `/client/apps/${this.app.id}` }, {});
156
- }
157
- async installApp(version) {
158
- return this.api.post({ adminPath: `/client/apps` },
159
- // eslint-disable-next-line camelcase
160
- { body: { app_id: this.app.id, version } });
161
- }
162
156
  installConfirmationMessage(storeToInstall, envToInstall, versionToInstall, existingVersion) {
163
157
  const message = [];
164
158
  if (existingVersion && semver.gt(versionToInstall, existingVersion)) {
@@ -176,7 +170,4 @@ Without a store specified, install the app in the Live environment of the curren
176
170
  message.push(style.appConfigValue(this.app.name), `v${versionToShow}`, `on ${style.storeId(storeToInstall)} [${envToInstall || 'live'}]?`);
177
171
  return message.join(' ');
178
172
  }
179
- async updateApp(version) {
180
- await this.api.put({ adminPath: `/client/apps/${this.app.id}` }, { body: { version } });
181
- }
182
173
  }
@@ -0,0 +1,15 @@
1
+ import { PushAppCommand } from '../../push-app-command.js';
2
+ export default class AppPull extends PushAppCommand {
3
+ static args: {
4
+ appId: import("@oclif/core/lib/interfaces/parser.js").Arg<string, Record<string, unknown>>;
5
+ targetPath: import("@oclif/core/lib/interfaces/parser.js").Arg<string, Record<string, unknown>>;
6
+ };
7
+ static description: string;
8
+ static examples: string[];
9
+ static flags: {
10
+ force: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
11
+ };
12
+ static summary: string;
13
+ logPulledChanges(pulled: string[], removed: string[]): void;
14
+ run(): Promise<void>;
15
+ }
@@ -0,0 +1,50 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import * as path from 'node:path';
3
+ import { ConfigPaths } from '../../lib/apps/index.js';
4
+ import style from '../../lib/style.js';
5
+ import { PushAppCommand } from '../../push-app-command.js';
6
+ export default class AppPull extends PushAppCommand {
7
+ static args = {
8
+ appId: Args.string({ default: '', description: 'app id to pull' }),
9
+ targetPath: Args.string({
10
+ default: '',
11
+ description: 'path to download app files into',
12
+ }),
13
+ };
14
+ static description = `Pull all app files, a specific file, or a specific configuration
15
+ type from an app in your store's test environment to your local machine.
16
+
17
+ If APPID is not specified, you will be prompted with a list of apps to choose from.
18
+
19
+ App file directories:
20
+ ${Object.values(ConfigPaths)
21
+ .map((dir) => style.path(`${dir}/`))
22
+ .join('\n')}\n${style.path(`frontend/`)}`;
23
+ static examples = [
24
+ 'swell app pull',
25
+ 'swell app pull example_app',
26
+ 'swell app pull example_app example-folder',
27
+ 'swell app pull --force',
28
+ ];
29
+ static flags = {
30
+ force: Flags.boolean({
31
+ default: false,
32
+ description: 'force pull all files',
33
+ }),
34
+ };
35
+ static summary = 'Pull app files from Swell to your local machine.';
36
+ logPulledChanges(pulled, removed) {
37
+ const typeLabel = this.appType === 'theme' ? 'theme' : 'app';
38
+ const changeCount = pulled.length + removed.length;
39
+ const pluralFiles = changeCount === 1 ? 'file' : 'files';
40
+ this.log(`Pulled ${changeCount} ${pluralFiles} from ${style.appConfigValue(this.app.name)} ${typeLabel} in ${style.path(path.resolve(this.appPath))}.`);
41
+ }
42
+ async run() {
43
+ const { args, flags } = await this.parse(AppPull);
44
+ const { force } = flags;
45
+ await this.ensureLoggedIn();
46
+ this.app = (await this.getAppToPull(args));
47
+ const { pulled, removed } = await this.pullAppConfigs(force);
48
+ this.logPulledChanges(pulled, removed);
49
+ }
50
+ }
@@ -1,20 +1,17 @@
1
- import { RemoteAppCommand } from '../../remote-app-command.js';
2
- export default class AppPush extends RemoteAppCommand {
1
+ import { PushAppCommand } from '../../push-app-command.js';
2
+ export default class AppPush extends PushAppCommand {
3
3
  static args: {
4
4
  file: import("@oclif/core/lib/interfaces/parser.js").Arg<string | undefined, Record<string, unknown>>;
5
5
  };
6
+ static delayOrientation: boolean;
6
7
  static description: string;
7
8
  static examples: string[];
8
- static flags: {
9
- file: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
10
- };
11
- static orientation: {
12
- env: string;
13
- };
9
+ static flags: any;
10
+ static orientation: any;
14
11
  static summary: string;
12
+ resolvePushPaths(file: string): {
13
+ filePath: string;
14
+ relativePath: string;
15
+ };
15
16
  run(): Promise<void>;
16
- private confirmRemoveInstalledApp;
17
- private logDashboardUrl;
18
- private pushConfigPath;
19
- private pushFile;
20
17
  }