@swell/cli 2.0.1-alpha.17 → 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 (67) hide show
  1. package/dist/app-command.d.ts +1 -1
  2. package/dist/app-command.js +3 -3
  3. package/dist/commands/app/dev.d.ts +3 -5
  4. package/dist/commands/app/dev.js +3 -6
  5. package/dist/commands/app/frontend/deploy.d.ts +1 -3
  6. package/dist/commands/app/frontend/deploy.js +2 -5
  7. package/dist/commands/app/frontend/dev.d.ts +4 -6
  8. package/dist/commands/app/frontend/dev.js +12 -15
  9. package/dist/commands/app/info.js +1 -3
  10. package/dist/commands/app/init.js +2 -2
  11. package/dist/commands/app/install.js +0 -1
  12. package/dist/commands/app/pull.d.ts +3 -3
  13. package/dist/commands/app/pull.js +16 -16
  14. package/dist/commands/app/push.d.ts +4 -4
  15. package/dist/commands/app/push.js +28 -31
  16. package/dist/commands/app/release.d.ts +3 -3
  17. package/dist/commands/app/release.js +43 -45
  18. package/dist/commands/app/version.d.ts +4 -4
  19. package/dist/commands/app/version.js +28 -28
  20. package/dist/commands/create/app.d.ts +15 -15
  21. package/dist/commands/create/app.js +66 -66
  22. package/dist/commands/create/frontend.js +4 -7
  23. package/dist/commands/env.d.ts +12 -0
  24. package/dist/commands/env.js +31 -0
  25. package/dist/commands/login.js +1 -3
  26. package/dist/commands/logs.js +0 -2
  27. package/dist/commands/theme/dev.d.ts +6 -8
  28. package/dist/commands/theme/dev.js +30 -33
  29. package/dist/commands/theme/init.d.ts +1 -1
  30. package/dist/commands/theme/init.js +1 -1
  31. package/dist/commands/theme/pull.d.ts +7 -7
  32. package/dist/commands/theme/pull.js +21 -21
  33. package/dist/commands/theme/push.d.ts +7 -7
  34. package/dist/commands/theme/push.js +24 -27
  35. package/dist/create-app-command.d.ts +7 -7
  36. package/dist/create-app-command.js +146 -147
  37. package/dist/create-config-command.js +0 -2
  38. package/dist/env/local.d.ts +8 -0
  39. package/dist/env/local.js +7 -0
  40. package/dist/env/production.d.ts +8 -0
  41. package/dist/env/production.js +7 -0
  42. package/dist/env/review.d.ts +8 -0
  43. package/dist/env/review.js +7 -0
  44. package/dist/env/staging.d.ts +8 -0
  45. package/dist/env/staging.js +7 -0
  46. package/dist/lib/api.d.ts +3 -3
  47. package/dist/lib/api.js +35 -35
  48. package/dist/lib/app-config.d.ts +2 -2
  49. package/dist/lib/app-config.js +12 -11
  50. package/dist/lib/apps/app-config.d.ts +19 -19
  51. package/dist/lib/apps/app-config.js +59 -65
  52. package/dist/lib/apps/index.d.ts +56 -56
  53. package/dist/lib/apps/index.js +40 -42
  54. package/dist/lib/apps/paths.d.ts +1 -1
  55. package/dist/lib/apps/paths.js +4 -4
  56. package/dist/lib/config.d.ts +4 -1
  57. package/dist/lib/config.js +35 -1
  58. package/dist/lib/constants.js +7 -8
  59. package/dist/lib/create/index.js +2 -2
  60. package/dist/lib/stores.d.ts +4 -2
  61. package/dist/lib/stores.js +4 -2
  62. package/dist/push-app-command.d.ts +34 -34
  63. package/dist/push-app-command.js +391 -402
  64. package/dist/remote-app-command.d.ts +24 -24
  65. package/dist/remote-app-command.js +245 -259
  66. package/oclif.manifest.json +152 -119
  67. package/package.json +2 -1
@@ -1,9 +1,8 @@
1
1
  import { Args, Flags } from '@oclif/core';
2
- import { ThemeConfigPaths, } from '../../lib/apps/index.js';
2
+ import { ThemeConfigPaths } from '../../lib/apps/index.js';
3
3
  import style from '../../lib/style.js';
4
4
  import AppPull from '../app/pull.js';
5
5
  export default class AppThemePull extends AppPull {
6
- appType = 'theme';
7
6
  static args = {
8
7
  appId: Args.string({
9
8
  default: '',
@@ -14,24 +13,7 @@ export default class AppThemePull extends AppPull {
14
13
  description: 'path to download theme files into',
15
14
  }),
16
15
  };
17
- static flags = {
18
- force: Flags.boolean({
19
- description: 'force pull all theme files',
20
- default: false,
21
- }),
22
- 'sync-app': Flags.boolean({
23
- description: 'pull app files in addition to theme files to',
24
- default: false,
25
- }),
26
- 'storefront-select': Flags.boolean({
27
- description: 'prompt to select a storefront to pull theme files to',
28
- default: false,
29
- }),
30
- 'storefront-id': Flags.string({
31
- description: 'identify a storefront to pull theme files from',
32
- }),
33
- };
34
- static summary = 'Pull theme files from Swell to your local machine.';
16
+ static delayOrientation = true;
35
17
  static description = `Pull all theme files, a specific file, or a specific configuration
36
18
  type from a theme in your store's test environment to your local machine.
37
19
 
@@ -49,8 +31,26 @@ ${Object.values(ThemeConfigPaths)
49
31
  'swell theme pull --storefront-select',
50
32
  'swell theme pull --storefront-id <id>',
51
33
  ];
34
+ static flags = {
35
+ force: Flags.boolean({
36
+ default: false,
37
+ description: 'force pull all theme files',
38
+ }),
39
+ 'storefront-id': Flags.string({
40
+ description: 'identify a storefront to pull theme files from',
41
+ }),
42
+ 'storefront-select': Flags.boolean({
43
+ default: false,
44
+ description: 'prompt to select a storefront to pull theme files to',
45
+ }),
46
+ 'sync-app': Flags.boolean({
47
+ default: false,
48
+ description: 'pull app files in addition to theme files to',
49
+ }),
50
+ };
52
51
  static orientation = {};
53
- static delayOrientation = true;
52
+ static summary = 'Pull theme files from Swell to your local machine.';
53
+ appType = 'theme';
54
54
  async run() {
55
55
  const { args, flags } = await this.parse(AppThemePull);
56
56
  const { force } = flags;
@@ -1,19 +1,19 @@
1
1
  import AppPush from '../app/push.js';
2
2
  export default class AppThemePush extends AppPush {
3
- appType: string;
4
3
  static args: {
5
4
  file: import("@oclif/core/lib/interfaces/parser.js").Arg<string | undefined, Record<string, unknown>>;
6
5
  };
6
+ static delayOrientation: boolean;
7
+ static description: string;
8
+ static examples: string[];
7
9
  static flags: {
8
10
  force: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
9
- 'sync-app': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
10
- 'storefront-select': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
11
11
  'storefront-id': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
12
+ 'storefront-select': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
13
+ 'sync-app': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
12
14
  };
13
- static summary: string;
14
- static description: string;
15
- static examples: string[];
16
15
  static orientation: {};
17
- static delayOrientation: boolean;
16
+ static summary: string;
17
+ appType: string;
18
18
  run(): Promise<void>;
19
19
  }
@@ -1,33 +1,15 @@
1
1
  import { Args, Flags } from '@oclif/core';
2
- import { ThemeConfigPaths, isPathDirectory, filePathExists, } from '../../lib/apps/index.js';
2
+ import { ThemeConfigPaths, filePathExists, isPathDirectory, } from '../../lib/apps/index.js';
3
3
  import style from '../../lib/style.js';
4
4
  import AppPush from '../app/push.js';
5
5
  export default class AppThemePush extends AppPush {
6
- appType = 'theme';
7
6
  static args = {
8
7
  file: Args.string({
9
8
  char: 'f',
10
9
  description: 'relative path to a configuration file or directory to push',
11
10
  }),
12
11
  };
13
- static flags = {
14
- force: Flags.boolean({
15
- description: 'force push all files',
16
- default: false,
17
- }),
18
- 'sync-app': Flags.boolean({
19
- description: 'push app files in addition to theme files',
20
- default: false,
21
- }),
22
- 'storefront-select': Flags.boolean({
23
- description: 'prompt to select a storefront to push theme files to',
24
- default: false,
25
- }),
26
- 'storefront-id': Flags.string({
27
- description: 'identify a storefront to push theme files to',
28
- }),
29
- };
30
- static summary = 'Push local files to your Swell theme.';
12
+ static delayOrientation = true;
31
13
  static description = `Push all theme files, a specific file, or a specific configuration
32
14
  type to an theme in your store's test environment.
33
15
 
@@ -51,8 +33,26 @@ ${Object.values(ThemeConfigPaths)
51
33
  'swell theme push --storefront-select',
52
34
  'swell theme push --storefront-id <id>',
53
35
  ];
36
+ static flags = {
37
+ force: Flags.boolean({
38
+ default: false,
39
+ description: 'force push all files',
40
+ }),
41
+ 'storefront-id': Flags.string({
42
+ description: 'identify a storefront to push theme files to',
43
+ }),
44
+ 'storefront-select': Flags.boolean({
45
+ default: false,
46
+ description: 'prompt to select a storefront to push theme files to',
47
+ }),
48
+ 'sync-app': Flags.boolean({
49
+ default: false,
50
+ description: 'push app files in addition to theme files',
51
+ }),
52
+ };
54
53
  static orientation = {};
55
- static delayOrientation = true;
54
+ static summary = 'Push local files to your Swell theme.';
55
+ appType = 'theme';
56
56
  async run() {
57
57
  const { args, flags } = await this.parse(AppThemePush);
58
58
  const { file } = args;
@@ -74,12 +74,9 @@ ${Object.values(ThemeConfigPaths)
74
74
  this.error(`Path ${style.path(file)} does not exist.`);
75
75
  }
76
76
  // Targeting a directory
77
- if (isPathDirectory(filePath)) {
78
- await this.pushFilePath(relativePath, force);
79
- }
80
- else {
81
- await this.pushFile(relativePath);
82
- }
77
+ await (isPathDirectory(filePath)
78
+ ? this.pushFilePath(relativePath, force)
79
+ : this.pushFile(relativePath));
83
80
  this.log();
84
81
  this.logStorefrontFrontendUrl(this.storefront);
85
82
  return;
@@ -1,20 +1,20 @@
1
1
  import { SwellCommand } from './swell-command.js';
2
2
  export declare abstract class CreateAppCommand extends SwellCommand {
3
- private devApi;
4
3
  static baseFlags: {
5
- yes: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
6
4
  frontend: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
7
5
  'storefront-app': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
6
+ yes: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
8
7
  };
8
+ private devApi;
9
9
  constructor(argv: string[], config: any);
10
- execWithStdio(cwd: string, command: string, onOutput?: (string: string) => false | any): Promise<void>;
11
10
  createAppConfigFolders(swellConfig: any): Promise<void>;
11
+ createFrontendApp(swellConfig: any, flags: any, directCreate?: boolean, kind?: string): Promise<boolean>;
12
+ createStorefrontApp(swellConfig: any, flags: any, directCreate?: boolean): Promise<boolean>;
13
+ createThemeApp(config: any, flags: any, installedStorefrontApp: any): Promise<boolean>;
12
14
  doesPackageManagerExist(packageManager: string): Promise<boolean>;
15
+ execWithStdio(cwd: string, command: string, onOutput?: (string: string) => any | false): Promise<void>;
13
16
  findPackageManager(pkg?: string): Promise<string | undefined>;
17
+ getInstalledStorefrontApps(): Promise<any[] | boolean>;
14
18
  setupPackage(name: string, config: any, pkg: string): Promise<void>;
15
19
  tryPackageSetup(name: string, config: any, pkg: string): Promise<void>;
16
- getInstalledStorefrontApps(): Promise<boolean | any[]>;
17
- createThemeApp(config: any, flags: any, installedStorefrontApp: any): Promise<boolean>;
18
- createStorefrontApp(swellConfig: any, flags: any, directCreate?: boolean): Promise<boolean>;
19
- createFrontendApp(swellConfig: any, flags: any, directCreate?: boolean, kind?: string): Promise<boolean>;
20
20
  }
@@ -1,10 +1,10 @@
1
1
  import { confirm, select } from '@inquirer/prompts';
2
2
  import { Flags } from '@oclif/core';
3
+ import { $ } from 'execa';
3
4
  import { exec } from 'node:child_process';
4
5
  import path from 'node:path';
6
+ import Stream from 'node:stream';
5
7
  import { promisify } from 'node:util';
6
- import { $ } from 'execa';
7
- import Stream from 'stream';
8
8
  import ora from 'ora';
9
9
  import Api from './lib/api.js';
10
10
  import { FrontendProjectTypes, getAllConfigPaths, writeFile, writeJsonFile, } from './lib/apps/index.js';
@@ -12,12 +12,7 @@ import style from './lib/style.js';
12
12
  import { SwellCommand } from './swell-command.js';
13
13
  const execAsync = promisify(exec);
14
14
  export class CreateAppCommand extends SwellCommand {
15
- devApi;
16
15
  static baseFlags = {
17
- yes: Flags.boolean({
18
- char: 'y',
19
- description: `accept all default values`,
20
- }),
21
16
  frontend: Flags.string({
22
17
  description: `create a starter framework for a hosted frontend`,
23
18
  options: FrontendProjectTypes.map(({ slug }) => slug),
@@ -25,17 +20,144 @@ export class CreateAppCommand extends SwellCommand {
25
20
  'storefront-app': Flags.string({
26
21
  description: `id of an installed storefront app to create a theme for, if applicable`,
27
22
  }),
23
+ yes: Flags.boolean({
24
+ char: 'y',
25
+ description: `accept all default values`,
26
+ }),
28
27
  };
28
+ devApi;
29
29
  constructor(argv, config) {
30
30
  super(argv, config);
31
31
  this.devApi = new Api(undefined, 'test');
32
32
  }
33
+ async createAppConfigFolders(swellConfig) {
34
+ for (const type of getAllConfigPaths(swellConfig.get('type'))) {
35
+ // Create a config folder
36
+ // eslint-disable-next-line no-await-in-loop
37
+ await execAsync(`mkdir -p ${type}`, {
38
+ cwd: path.dirname(swellConfig.path),
39
+ });
40
+ }
41
+ }
42
+ async createFrontendApp(swellConfig, flags, directCreate, kind) {
43
+ const spinner = ora();
44
+ const configPath = path.dirname(swellConfig.path);
45
+ const frameworkType = flags.frontend ||
46
+ (await select({
47
+ choices: [
48
+ ...FrontendProjectTypes.map(({ name, slug }) => ({
49
+ name,
50
+ value: slug,
51
+ })),
52
+ ...(directCreate
53
+ ? []
54
+ : [
55
+ {
56
+ name: 'Do not install a starter framework',
57
+ value: null,
58
+ },
59
+ ]),
60
+ ],
61
+ message: directCreate
62
+ ? `Choose a framework for your hosted${kind ? ` ${kind} ` : ' '}app frontend`
63
+ : `Install a framework for your hosted${kind ? ` ${kind} ` : ' '}app frontend?`,
64
+ }));
65
+ if (frameworkType) {
66
+ const projectType = FrontendProjectTypes.find((type) => type.slug === frameworkType);
67
+ if (!projectType) {
68
+ this.error(`Could not find project type: ${frameworkType}`);
69
+ }
70
+ this.log();
71
+ spinner.start(`Creating ${projectType?.name} frontend app (this may take a while)...`);
72
+ try {
73
+ await execAsync(`mkdir -p frontend`, {
74
+ cwd: configPath,
75
+ });
76
+ await execAsync(projectType.installCommand, {
77
+ cwd: configPath,
78
+ });
79
+ // Use this command to debug output, i.e.e when command becomes non-responsive
80
+ /* await this.execWithStdio(
81
+ configPath,
82
+ projectType.installCommand,
83
+ ); */
84
+ }
85
+ catch (error) {
86
+ spinner.fail(`Error creating ${projectType?.name} app:\n`);
87
+ this.log(error.stdout);
88
+ this.log();
89
+ return false;
90
+ }
91
+ spinner.succeed(`${projectType?.name} initialized app in ${configPath}/frontend/`);
92
+ if (directCreate) {
93
+ this.log();
94
+ }
95
+ return true;
96
+ }
97
+ return false;
98
+ }
99
+ async createStorefrontApp(swellConfig, flags, directCreate) {
100
+ return this.createFrontendApp(swellConfig, flags, directCreate, 'storefront');
101
+ }
102
+ async createThemeApp(config, flags, installedStorefrontApp) {
103
+ const spinner = ora();
104
+ const configPath = path.dirname(config.path);
105
+ const defaultThemeConfigs = await this.devApi.get({
106
+ adminPath: `/client/apps/${installedStorefrontApp.app_id}/theme-template-configs`,
107
+ });
108
+ if (defaultThemeConfigs.results?.length > 0) {
109
+ const { name: appName, version: appVersion } = installedStorefrontApp.app;
110
+ const shouldCreate = flags.yes ||
111
+ (await confirm({
112
+ message: `Create a theme template for ${style.appConfigValue(appName)} ${appVersion ? `v${appVersion}` : ''}?`,
113
+ }));
114
+ if (shouldCreate) {
115
+ this.log();
116
+ spinner.start(`Creating theme template...`);
117
+ try {
118
+ await execAsync(`mkdir -p theme`, {
119
+ cwd: configPath,
120
+ });
121
+ for (const themeConfig of defaultThemeConfigs.results) {
122
+ const filePath = themeConfig.file_path.replace(/^frontend\/theme-template\//, '');
123
+ const fileContent = themeConfig.file_data;
124
+ const isJson = filePath.endsWith('.json');
125
+ // eslint-disable-next-line no-await-in-loop
126
+ await execAsync(`mkdir -p ${path.dirname(filePath)}`, {
127
+ cwd: configPath,
128
+ });
129
+ // eslint-disable-next-line no-await-in-loop
130
+ await (isJson
131
+ ? writeJsonFile(path.join(configPath, filePath), fileContent)
132
+ : writeFile(path.join(configPath, filePath), fileContent));
133
+ }
134
+ }
135
+ catch (error) {
136
+ spinner.fail(`Error creating theme template:\n`);
137
+ this.log(error.stdout);
138
+ this.log();
139
+ return false;
140
+ }
141
+ spinner.succeed(`Theme template initialized in ${configPath}/theme/`);
142
+ }
143
+ }
144
+ return true;
145
+ }
146
+ async doesPackageManagerExist(packageManager) {
147
+ try {
148
+ await execAsync(`${packageManager} --version`);
149
+ return true;
150
+ }
151
+ catch {
152
+ return false;
153
+ }
154
+ }
33
155
  async execWithStdio(cwd, command, onOutput) {
34
156
  const $$ = $({
35
157
  cwd,
36
158
  shell: true,
37
- stdin: 'inherit',
38
159
  stderr: 'inherit',
160
+ stdin: 'inherit',
39
161
  stdout: 'pipe',
40
162
  });
41
163
  const outStream = new Stream.Writable();
@@ -50,26 +172,8 @@ export class CreateAppCommand extends SwellCommand {
50
172
  try {
51
173
  await $$ `${command}`.pipeStdout?.(outStream);
52
174
  }
53
- catch (err) {
54
- console.log(err);
55
- }
56
- }
57
- async createAppConfigFolders(swellConfig) {
58
- for (const type of getAllConfigPaths(swellConfig.get('type'))) {
59
- // Create a config folder
60
- // eslint-disable-next-line no-await-in-loop
61
- await execAsync(`mkdir -p ${type}`, {
62
- cwd: path.dirname(swellConfig.path),
63
- });
64
- }
65
- }
66
- async doesPackageManagerExist(packageManager) {
67
- try {
68
- await execAsync(`${packageManager} --version`);
69
- return true;
70
- }
71
- catch {
72
- return false;
175
+ catch (error) {
176
+ console.log(error);
73
177
  }
74
178
  }
75
179
  async findPackageManager(pkg = '') {
@@ -89,6 +193,20 @@ export class CreateAppCommand extends SwellCommand {
89
193
  }
90
194
  }
91
195
  }
196
+ async getInstalledStorefrontApps() {
197
+ const spinner = ora();
198
+ spinner.start('Retrieving installed storefront apps...');
199
+ const installedApps = await this.devApi.get({
200
+ adminPath: `/client/apps`,
201
+ });
202
+ const storefrontInstalledApps = installedApps.results.filter((installedApp) => installedApp.app?.type === 'storefront');
203
+ if (storefrontInstalledApps.length === 0) {
204
+ spinner.fail(`You must have at least one storefront app installed in your ${style.appEnv('test')} environment before creating a theme.`);
205
+ return false;
206
+ }
207
+ spinner.stop();
208
+ return storefrontInstalledApps;
209
+ }
92
210
  async setupPackage(name, config, pkg) {
93
211
  const execAsync = promisify(exec);
94
212
  const configPath = path.dirname(config.path);
@@ -132,123 +250,4 @@ export class CreateAppCommand extends SwellCommand {
132
250
  this.log(`There was an error setting up the package manager: ${error.message}`);
133
251
  }
134
252
  }
135
- async getInstalledStorefrontApps() {
136
- const spinner = ora();
137
- spinner.start('Retrieving installed storefront apps...');
138
- const installedApps = await this.devApi.get({
139
- adminPath: `/client/apps`,
140
- });
141
- const storefrontInstalledApps = installedApps.results.filter((installedApp) => installedApp.app?.type === 'storefront');
142
- if (storefrontInstalledApps.length === 0) {
143
- spinner.fail(`You must have at least one storefront app installed in your ${style.appEnv('test')} environment before creating a theme.`);
144
- return false;
145
- }
146
- spinner.stop();
147
- return storefrontInstalledApps;
148
- }
149
- async createThemeApp(config, flags, installedStorefrontApp) {
150
- const spinner = ora();
151
- const configPath = path.dirname(config.path);
152
- const defaultThemeConfigs = await this.devApi.get({
153
- adminPath: `/client/apps/${installedStorefrontApp.app_id}/theme-template-configs`,
154
- });
155
- if (defaultThemeConfigs.results?.length > 0) {
156
- const { name: appName, version: appVersion } = installedStorefrontApp.app;
157
- const shouldCreate = flags.yes ||
158
- (await confirm({
159
- message: `Create a theme template for ${style.appConfigValue(appName)} ${appVersion ? `v${appVersion}` : ''}?`,
160
- }));
161
- if (shouldCreate) {
162
- this.log();
163
- spinner.start(`Creating theme template...`);
164
- try {
165
- await execAsync(`mkdir -p theme`, {
166
- cwd: configPath,
167
- });
168
- for (const themeConfig of defaultThemeConfigs.results) {
169
- const filePath = themeConfig.file_path.replace(/^frontend\/theme-template\//, '');
170
- const fileContent = themeConfig.file_data;
171
- const isJson = filePath.endsWith('.json');
172
- await execAsync(`mkdir -p ${path.dirname(filePath)}`, {
173
- cwd: configPath,
174
- });
175
- if (isJson) {
176
- await writeJsonFile(path.join(configPath, filePath), fileContent);
177
- }
178
- else {
179
- await writeFile(path.join(configPath, filePath), fileContent);
180
- }
181
- }
182
- }
183
- catch (err) {
184
- spinner.fail(`Error creating theme template:\n`);
185
- this.log(err.stdout);
186
- this.log();
187
- return false;
188
- }
189
- spinner.succeed(`Theme template initialized in ${configPath}/theme/`);
190
- }
191
- }
192
- return true;
193
- }
194
- async createStorefrontApp(swellConfig, flags, directCreate) {
195
- return await this.createFrontendApp(swellConfig, flags, directCreate, 'storefront');
196
- }
197
- async createFrontendApp(swellConfig, flags, directCreate, kind) {
198
- const spinner = ora();
199
- const configPath = path.dirname(swellConfig.path);
200
- const frameworkType = flags.frontend ||
201
- (await select({
202
- choices: [
203
- ...FrontendProjectTypes.map(({ name, slug }) => ({
204
- name,
205
- value: slug,
206
- })),
207
- ...(directCreate
208
- ? []
209
- : [
210
- {
211
- name: 'Do not install a starter framework',
212
- value: null,
213
- },
214
- ]),
215
- ],
216
- message: directCreate
217
- ? `Choose a framework for your hosted${kind ? ` ${kind} ` : ' '}app frontend`
218
- : `Install a framework for your hosted${kind ? ` ${kind} ` : ' '}app frontend?`,
219
- }));
220
- if (frameworkType) {
221
- const projectType = FrontendProjectTypes.find((type) => type.slug === frameworkType);
222
- if (!projectType) {
223
- this.error(`Could not find project type: ${frameworkType}`);
224
- }
225
- this.log();
226
- spinner.start(`Creating ${projectType?.name} frontend app (this may take a while)...`);
227
- try {
228
- await execAsync(`mkdir -p frontend`, {
229
- cwd: configPath,
230
- });
231
- await execAsync(projectType.installCommand, {
232
- cwd: configPath,
233
- });
234
- // Use this command to debug output, i.e.e when command becomes non-responsive
235
- /* await this.execWithStdio(
236
- configPath,
237
- projectType.installCommand,
238
- ); */
239
- }
240
- catch (err) {
241
- spinner.fail(`Error creating ${projectType?.name} app:\n`);
242
- this.log(err.stdout);
243
- this.log();
244
- return false;
245
- }
246
- spinner.succeed(`${projectType?.name} initialized app in ${configPath}/frontend/`);
247
- if (directCreate) {
248
- this.log();
249
- }
250
- return true;
251
- }
252
- return false;
253
- }
254
253
  }
@@ -45,9 +45,7 @@ export class CreateConfigCommand extends AppCommand {
45
45
  const models = await this.api.post({ adminPath: `/data/$get/:models` }, {
46
46
  body: {
47
47
  abstract: { $ne: true },
48
- // eslint-disable-next-line camelcase
49
48
  app_id: null,
50
- // eslint-disable-next-line camelcase
51
49
  client_id: null,
52
50
  deprecated: { $ne: true },
53
51
  fields: 'name, namespace',
@@ -0,0 +1,8 @@
1
+ declare namespace _default {
2
+ let API_BASE_URL: string;
3
+ let ADMIN_API_BASE_URL: string;
4
+ let LOGIN_HOST: string;
5
+ let APP_PAGES_HOST: string;
6
+ let STOREFRONT_FRONTEND_HOST: string;
7
+ }
8
+ export default _default;
@@ -0,0 +1,7 @@
1
+ export default {
2
+ API_BASE_URL: 'https://localapi.schema.io:4443',
3
+ ADMIN_API_BASE_URL: 'http://${STORE_ID}.swell.test:4001/admin/api',
4
+ LOGIN_HOST: 'http://${STORE_ID}.swell.test:3000',
5
+ APP_PAGES_HOST: 'http://${STORE_ID}--${APP_ID}--${ENV}.swell.test:4001',
6
+ STOREFRONT_FRONTEND_HOST: 'http://${BRANCH_PREFIX}${STOREFRONT_SLUG}.swell.test:4001',
7
+ };
@@ -0,0 +1,8 @@
1
+ declare namespace _default {
2
+ let API_BASE_URL: string;
3
+ let ADMIN_API_BASE_URL: string;
4
+ let LOGIN_HOST: string;
5
+ let APP_PAGES_HOST: string;
6
+ let STOREFRONT_FRONTEND_HOST: string;
7
+ }
8
+ export default _default;
@@ -0,0 +1,7 @@
1
+ export default {
2
+ API_BASE_URL: 'https://api.swell.store',
3
+ ADMIN_API_BASE_URL: 'https://${STORE_ID}.swell.store/admin/api',
4
+ LOGIN_HOST: 'https://${STORE_ID}.swell.store',
5
+ APP_PAGES_HOST: 'https://${STORE_ID}--${APP_ID}--${ENV}.swell.store',
6
+ STOREFRONT_FRONTEND_HOST: 'https://${BRANCH_PREFIX}${STOREFRONT_SLUG}.swell.store',
7
+ };
@@ -0,0 +1,8 @@
1
+ declare namespace _default {
2
+ let API_BASE_URL: string;
3
+ let ADMIN_API_BASE_URL: string;
4
+ let LOGIN_HOST: string;
5
+ let APP_PAGES_HOST: string;
6
+ let STOREFRONT_FRONTEND_HOST: string;
7
+ }
8
+ export default _default;
@@ -0,0 +1,7 @@
1
+ export default {
2
+ API_BASE_URL: 'https://${REVIEW_DOMAIN}.rav2.swell.store',
3
+ ADMIN_API_BASE_URL: 'https://${STORE_ID}.${REVIEW_DOMAIN}.rav2.swell.store/admin/api',
4
+ LOGIN_HOST: 'https://${REVIEW_DOMAIN}.rav2.swell.store',
5
+ APP_PAGES_HOST: 'https://${STORE_ID}--${APP_ID}--${ENV}.${REVIEW_DOMAIN}.rav2.swell.store',
6
+ STOREFRONT_FRONTEND_HOST: 'https://${BRANCH_PREFIX}${STOREFRONT_SLUG}.${REVIEW_DOMAIN}.rav2.swell.store',
7
+ };
@@ -0,0 +1,8 @@
1
+ declare namespace _default {
2
+ let API_BASE_URL: string;
3
+ let ADMIN_API_BASE_URL: string;
4
+ let LOGIN_HOST: string;
5
+ let APP_PAGES_HOST: string;
6
+ let STOREFRONT_FRONTEND_HOST: string;
7
+ }
8
+ export default _default;
@@ -0,0 +1,7 @@
1
+ export default {
2
+ API_BASE_URL: 'https://staging.swell.store',
3
+ ADMIN_API_BASE_URL: 'https://${STORE_ID}.staging.swell.store/admin/api',
4
+ LOGIN_HOST: 'https://staging.swell.store',
5
+ APP_PAGES_HOST: 'https://${STORE_ID}--${APP_ID}--${ENV}.staging.swell.store',
6
+ STOREFRONT_FRONTEND_HOST: 'https://${BRANCH_PREFIX}${STOREFRONT_SLUG}.staging.swell.store',
7
+ };
package/dist/lib/api.d.ts CHANGED
@@ -4,12 +4,12 @@ export default class Api {
4
4
  private storeId;
5
5
  constructor(storeId?: string, envId?: string, secretKey?: string);
6
6
  api(pathOpts: Api.Paths, options: Api.RequestOptions): Promise<any>;
7
- isAdmin(): boolean;
8
- waitForAsyncResponse(response: any, pathOpts: Api.Paths, options?: Api.RequestOptions): Promise<any>;
7
+ delete(pathOpts: Api.Paths, options?: Api.RequestOptions): Promise<any>;
9
8
  get(pathOpts: Api.Paths, options?: Api.RequestOptions): Promise<any>;
9
+ isAdmin(): boolean;
10
10
  post(pathOpts: Api.Paths, options?: Api.RequestOptions): Promise<any>;
11
11
  put(pathOpts: Api.Paths, options?: Api.RequestOptions): Promise<any>;
12
- delete(pathOpts: Api.Paths, options?: Api.RequestOptions): Promise<any>;
13
12
  setStoreEnv(storeId: string, envId?: string): void;
14
13
  truncatePath(path: string | undefined): string | undefined;
14
+ waitForAsyncResponse(response: any, pathOpts: Api.Paths, options?: Api.RequestOptions): Promise<any>;
15
15
  }