@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
@@ -5,97 +5,97 @@ import { AppConfig } from './app-config.js';
5
5
  * configuration that developers define.
6
6
  */
7
7
  type App = {
8
- id?: string;
8
+ categories?: Array<string>;
9
9
  client?: any;
10
10
  client_id?: string;
11
+ compatibilities?: {
12
+ [key: string]: string;
13
+ };
11
14
  configs?: AppConfig[];
12
15
  date_created?: string;
13
16
  date_updated?: string;
14
17
  description?: string;
15
- name?: string;
16
- type?: string;
18
+ extensions?: Array<any>;
19
+ features?: Array<string>;
20
+ frontend?: {
21
+ deployment?: null | object;
22
+ deployment_hash?: string;
23
+ deployment_id?: string;
24
+ framework?: string;
25
+ service?: string;
26
+ url?: string;
27
+ };
28
+ highlights?: Array<{
29
+ id: string;
30
+ image_src?: unknown;
31
+ title: string;
32
+ }>;
33
+ id?: string;
34
+ installed?: {
35
+ date_created: string;
36
+ id: string;
37
+ };
17
38
  kind?: string;
39
+ logo_icon?: unknown;
40
+ name?: string;
41
+ preview_image?: unknown;
42
+ preview_mobile_image?: unknown;
18
43
  private_id?: string;
19
44
  public_id?: string;
20
45
  published?: boolean;
21
- version?: string;
22
- compatibilities?: {
23
- [key: string]: string;
24
- };
46
+ purchase_options?: Array<string>;
25
47
  storefront?: {
26
48
  [key: string]: any;
27
49
  };
28
- theme?: {
29
- [key: string]: any;
30
- };
31
- logo_icon?: unknown;
32
- preview_image?: unknown;
33
- preview_mobile_image?: unknown;
34
- categories?: Array<string>;
35
- use_cases?: Array<string>;
36
- purchase_options?: Array<string>;
37
- features?: Array<string>;
38
- highlights?: Array<{
39
- id: string;
40
- title: string;
41
- image_src?: unknown;
42
- }>;
43
50
  styles?: Array<{
44
- id: string;
45
- label: string;
46
51
  color: string;
47
52
  color_alt?: string;
53
+ id: string;
54
+ label: string;
48
55
  preview_image?: unknown;
49
56
  preview_mobile_image?: unknown;
50
57
  }>;
51
- extensions?: Array<any>;
52
- frontend?: {
53
- url?: string;
54
- service?: string;
55
- framework?: string;
56
- deployment_id?: string;
57
- deployment_hash?: string;
58
- deployment?: object | null;
59
- };
60
- installed?: {
61
- id: string;
62
- date_created: string;
58
+ theme?: {
59
+ [key: string]: any;
63
60
  };
61
+ type?: string;
62
+ use_cases?: Array<string>;
63
+ version?: string;
64
64
  };
65
65
  declare enum SwellJsonFields {
66
+ DESCRIPTION = "description",
67
+ EXTENSIONS = "extensions",
66
68
  ID = "id",
67
- NAME = "name",
68
- TYPE = "type",
69
69
  KIND = "kind",
70
- VERSION = "version",
71
- DESCRIPTION = "description",
70
+ NAME = "name",
71
+ PERMISSIONS = "permissions",
72
72
  STOREFRONT = "storefront",
73
73
  THEME = "theme",
74
- PERMISSIONS = "permissions",
75
- EXTENSIONS = "extensions"
74
+ TYPE = "type",
75
+ VERSION = "version"
76
76
  }
77
77
  type AppVersion = {
78
78
  date_created: string;
79
+ description?: string;
79
80
  id: string;
80
81
  name: string;
81
- version: string;
82
- description?: string;
83
- released?: boolean;
84
- release_notes?: string;
85
82
  published?: boolean;
83
+ release_notes?: string;
84
+ released?: boolean;
86
85
  supported?: boolean;
86
+ version: string;
87
87
  };
88
88
  declare enum ConfigType {
89
89
  ASSET = "asset",
90
90
  CONTENT = "content",
91
+ FILE = "file",
92
+ FRONTEND = "frontend",
91
93
  FUNCTION = "function",
92
94
  MODEL = "model",
93
95
  NOTIFICATION = "notification",
94
96
  SETTING = "setting",
95
- WEBHOOK = "webhook",
96
- FRONTEND = "frontend",
97
97
  THEME = "theme",
98
- FILE = "file"
98
+ WEBHOOK = "webhook"
99
99
  }
100
100
  declare const StorefrontConfigTypes: string[];
101
101
  declare const ThemeConfigTypes: string[];
@@ -113,13 +113,13 @@ declare enum ConfigInputFields {
113
113
  VERSION = "version"
114
114
  }
115
115
  type FrontendProjectType = {
116
- name: string;
117
- slug: string;
116
+ buildCommand: string;
118
117
  configFileName: string;
119
118
  deployPath: string;
120
- installCommand: string;
121
- buildCommand: string;
122
119
  devCommand: string;
120
+ installCommand: string;
121
+ name: string;
122
+ slug: string;
123
123
  };
124
124
  declare const FrontendProjectTypes: Array<FrontendProjectType>;
125
125
  declare function getAppSlugId(app: App): string | undefined;
@@ -138,10 +138,10 @@ declare function findAppConfig(app: App, filePath: string, configType: ConfigTyp
138
138
  /**
139
139
  * Get files to push in batches prioritized by dependencies
140
140
  *
141
- * @param appConfigs - List of app configs
141
+ * @param configs - List of app configs
142
142
  * @returns {Array} Batches of files to push
143
143
  */
144
144
  declare function batchAppFilesByType(configs: AppConfig[]): Array<any>;
145
- export { App, AppVersion, SwellJsonFields, ConfigInputFields, ConfigPaths, ConfigPathsType, StorefrontConfigPaths, StorefrontConfigTypes, ThemeConfigTypes, ThemeConfigPaths, ConfigType, FrontendProjectType, FrontendProjectTypes, getAppSlugId, appConfigFromFile, appAssetImage, batchAppFilesByType, filePathExists, findAppConfig, getConfigTypeFromPath, getConfigTypeKeyFromValue, writeFile, writeJsonFile, deleteFile, hashFile, hashString, getFrontendProjectType, };
145
+ export { App, AppVersion, ConfigInputFields, ConfigPaths, ConfigPathsType, ConfigType, FrontendProjectType, FrontendProjectTypes, StorefrontConfigPaths, StorefrontConfigTypes, SwellJsonFields, ThemeConfigPaths, ThemeConfigTypes, appAssetImage, appConfigFromFile, batchAppFilesByType, deleteFile, filePathExists, findAppConfig, getAppSlugId, getConfigTypeFromPath, getConfigTypeKeyFromValue, getFrontendProjectType, hashFile, hashString, writeFile, writeJsonFile, };
146
146
  export { AppConfig, FunctionProcessingError, IgnoringFileError, } from './app-config.js';
147
- export { globAllFilesByPath, allConfigDirsPaths, allConfigFilesPaths, allConfigFilesPathsByType, allConfigFilesInDir, allBaseFilesInDir, isPathDirectory, getAllConfigPaths, } from './paths.js';
147
+ export { allBaseFilesInDir, allConfigDirsPaths, allConfigFilesInDir, allConfigFilesPaths, allConfigFilesPathsByType, getAllConfigPaths, globAllFilesByPath, isPathDirectory, } from './paths.js';
@@ -1,34 +1,34 @@
1
+ import { hash as blake3hash } from 'blake3-wasm';
2
+ import { pluralize, titleize } from 'inflection';
1
3
  import * as fs from 'node:fs';
2
4
  import * as path from 'node:path';
3
- import { pluralize, titleize } from 'inflection';
4
- import { hash as blake3hash } from 'blake3-wasm';
5
- import { AppConfig } from './app-config.js';
6
5
  import { toAppId } from '../create/index.js';
6
+ import { AppConfig } from './app-config.js';
7
7
  var SwellJsonFields;
8
8
  (function (SwellJsonFields) {
9
+ SwellJsonFields["DESCRIPTION"] = "description";
10
+ SwellJsonFields["EXTENSIONS"] = "extensions";
9
11
  SwellJsonFields["ID"] = "id";
10
- SwellJsonFields["NAME"] = "name";
11
- SwellJsonFields["TYPE"] = "type";
12
12
  SwellJsonFields["KIND"] = "kind";
13
- SwellJsonFields["VERSION"] = "version";
14
- SwellJsonFields["DESCRIPTION"] = "description";
13
+ SwellJsonFields["NAME"] = "name";
14
+ SwellJsonFields["PERMISSIONS"] = "permissions";
15
15
  SwellJsonFields["STOREFRONT"] = "storefront";
16
16
  SwellJsonFields["THEME"] = "theme";
17
- SwellJsonFields["PERMISSIONS"] = "permissions";
18
- SwellJsonFields["EXTENSIONS"] = "extensions";
17
+ SwellJsonFields["TYPE"] = "type";
18
+ SwellJsonFields["VERSION"] = "version";
19
19
  })(SwellJsonFields || (SwellJsonFields = {}));
20
20
  var ConfigType;
21
21
  (function (ConfigType) {
22
22
  ConfigType["ASSET"] = "asset";
23
23
  ConfigType["CONTENT"] = "content";
24
+ ConfigType["FILE"] = "file";
25
+ ConfigType["FRONTEND"] = "frontend";
24
26
  ConfigType["FUNCTION"] = "function";
25
27
  ConfigType["MODEL"] = "model";
26
28
  ConfigType["NOTIFICATION"] = "notification";
27
29
  ConfigType["SETTING"] = "setting";
28
- ConfigType["WEBHOOK"] = "webhook";
29
- ConfigType["FRONTEND"] = "frontend";
30
30
  ConfigType["THEME"] = "theme";
31
- ConfigType["FILE"] = "file";
31
+ ConfigType["WEBHOOK"] = "webhook";
32
32
  })(ConfigType || (ConfigType = {}));
33
33
  // Models and content should come first in order
34
34
  const ConfigTypeBatchOrder = [
@@ -57,20 +57,18 @@ const StandardConfigTypes = [
57
57
  ];
58
58
  const StorefrontConfigTypes = ['FRONTEND', 'ASSET', 'SETTING'];
59
59
  const ThemeConfigTypes = ['THEME', 'ASSET'];
60
- const getConfigPaths = (types) => {
61
- return {
62
- ...Object.fromEntries(Object.keys(ConfigType)
63
- .filter((type) => !types || types.find((inType) => inType === type))
64
- .map((type) => [
65
- type,
66
- // a bit of a hack to make the path singular for content configs
67
- // need to refactor this to a function if we add more exceptions
68
- type === 'CONTENT' || type === 'FRONTEND' || type === 'THEME'
69
- ? type.toLowerCase()
70
- : pluralize(type.toLowerCase()),
71
- ])),
72
- };
73
- };
60
+ const getConfigPaths = (types) => ({
61
+ ...Object.fromEntries(Object.keys(ConfigType)
62
+ .filter((type) => !types || types.find((inType) => inType === type))
63
+ .map((type) => [
64
+ type,
65
+ // a bit of a hack to make the path singular for content configs
66
+ // need to refactor this to a function if we add more exceptions
67
+ type === 'CONTENT' || type === 'FRONTEND' || type === 'THEME'
68
+ ? type.toLowerCase()
69
+ : pluralize(type.toLowerCase()),
70
+ ])),
71
+ });
74
72
  const ConfigPaths = {
75
73
  ...getConfigPaths(StandardConfigTypes),
76
74
  };
@@ -90,22 +88,22 @@ var ConfigInputFields;
90
88
  })(ConfigInputFields || (ConfigInputFields = {}));
91
89
  const FrontendProjectTypes = [
92
90
  {
93
- name: 'Next.js',
94
- slug: 'nextjs',
91
+ buildCommand: 'npx @cloudflare/next-on-pages',
95
92
  configFileName: 'next.config',
96
93
  deployPath: '.vercel/output/static',
97
- installCommand: 'npx create-next-app@latest frontend --typescript --use-npm --src-dir --app --eslint --import-alias "@/*" --tailwind',
98
- buildCommand: 'npx @cloudflare/next-on-pages',
99
94
  devCommand: 'npx next dev --port ${PORT}',
95
+ installCommand: 'npx create-next-app@latest frontend --typescript --use-npm --src-dir --app --eslint --import-alias "@/*" --tailwind',
96
+ name: 'Next.js',
97
+ slug: 'nextjs',
100
98
  },
101
99
  {
102
- name: 'Astro',
103
- slug: 'astro',
100
+ buildCommand: 'npx astro build',
104
101
  configFileName: 'astro.config',
105
102
  deployPath: 'dist',
106
- installCommand: 'npm create astro@latest frontend -- --install --no-git --yes --skip-houston --typescript strict',
107
- buildCommand: 'npx astro build',
108
103
  devCommand: 'npx astro dev --port ${PORT}',
104
+ installCommand: 'npm create astro@latest frontend -- --install --no-git --yes --skip-houston --typescript strict',
105
+ name: 'Astro',
106
+ slug: 'astro',
109
107
  },
110
108
  ];
111
109
  const frontendProjectConfigExtensions = ['.mjs', '.js'];
@@ -188,7 +186,7 @@ async function writeJsonFile(file, data = {}) {
188
186
  function hashFile(filePath, fileContents) {
189
187
  const contents = fileContents ?? fs.readFileSync(filePath);
190
188
  const base64Contents = contents.toString('base64');
191
- const extension = path.extname(filePath).substring(1);
189
+ const extension = path.extname(filePath).slice(1);
192
190
  return hashString(base64Contents + extension);
193
191
  }
194
192
  function hashString(contents) {
@@ -208,11 +206,11 @@ function appAssetImage(appPath, fileName) {
208
206
  function appConfigFromFile(filePath, configType, appPath) {
209
207
  const { name } = path.parse(filePath);
210
208
  const config = AppConfig.create({
211
- name,
212
- filePath,
213
209
  appPath,
214
- type: configType || 'file',
215
210
  file_path: filePath,
211
+ filePath,
212
+ name,
213
+ type: configType || 'file',
216
214
  });
217
215
  // Do not allow files larger than 10MB
218
216
  if (config.mbSize && config.mbSize > 10) {
@@ -228,7 +226,7 @@ function findAppConfig(app, filePath, configType) {
228
226
  /**
229
227
  * Get files to push in batches prioritized by dependencies
230
228
  *
231
- * @param appConfigs - List of app configs
229
+ * @param configs - List of app configs
232
230
  * @returns {Array} Batches of files to push
233
231
  */
234
232
  function batchAppFilesByType(configs) {
@@ -260,8 +258,8 @@ function batchAppFilesByType(configs) {
260
258
  // Add base files if config types are not specified
261
259
  return batches;
262
260
  }
263
- export { SwellJsonFields, ConfigInputFields, ConfigPaths, StorefrontConfigPaths, StorefrontConfigTypes, ThemeConfigTypes, ThemeConfigPaths, ConfigType, FrontendProjectTypes,
261
+ export { ConfigInputFields, ConfigPaths, ConfigType, FrontendProjectTypes, StorefrontConfigPaths, StorefrontConfigTypes, SwellJsonFields, ThemeConfigPaths, ThemeConfigTypes, appAssetImage, appConfigFromFile, batchAppFilesByType, deleteFile, filePathExists, findAppConfig,
264
262
  // functions
265
- getAppSlugId, appConfigFromFile, appAssetImage, batchAppFilesByType, filePathExists, findAppConfig, getConfigTypeFromPath, getConfigTypeKeyFromValue, writeFile, writeJsonFile, deleteFile, hashFile, hashString, getFrontendProjectType, };
263
+ getAppSlugId, getConfigTypeFromPath, getConfigTypeKeyFromValue, getFrontendProjectType, hashFile, hashString, writeFile, writeJsonFile, };
266
264
  export { AppConfig, FunctionProcessingError, IgnoringFileError, } from './app-config.js';
267
- export { globAllFilesByPath, allConfigDirsPaths, allConfigFilesPaths, allConfigFilesPathsByType, allConfigFilesInDir, allBaseFilesInDir, isPathDirectory, getAllConfigPaths, } from './paths.js';
265
+ export { allBaseFilesInDir, allConfigDirsPaths, allConfigFilesInDir, allConfigFilesPaths, allConfigFilesPathsByType, getAllConfigPaths, globAllFilesByPath, isPathDirectory, } from './paths.js';
@@ -22,4 +22,4 @@ declare function allConfigFilesInDir(appPath: string, dirPath: string, configTyp
22
22
  declare function allBaseFilesInDir(appPath: string): Generator<string, void, unknown>;
23
23
  declare function getAllConfigPaths(appType: string): Array<string>;
24
24
  declare function isPathDirectory(path: string): boolean;
25
- export { allConfigDirsPaths, allConfigFilesPaths, allConfigFilesPathsByType, allConfigFilesInDir, allBaseFilesInDir, globAllFilesByPath, isPathDirectory, getAllConfigPaths, };
25
+ export { allBaseFilesInDir, allConfigDirsPaths, allConfigFilesInDir, allConfigFilesPaths, allConfigFilesPathsByType, getAllConfigPaths, globAllFilesByPath, isPathDirectory, };
@@ -1,6 +1,6 @@
1
+ import { globbySync } from 'globby';
1
2
  import * as fs from 'node:fs';
2
3
  import * as path from 'node:path';
3
- import { globbySync } from 'globby';
4
4
  import { ConfigPaths, ConfigType, StorefrontConfigPaths, ThemeConfigPaths, filePathExists, } from './index.js';
5
5
  function globFiles(pattern, appPath, dirPath = '.', options = {}) {
6
6
  const filePaths = globbySync(`${dirPath}${path.sep}${pattern}`, {
@@ -8,6 +8,7 @@ function globFiles(pattern, appPath, dirPath = '.', options = {}) {
8
8
  dot: true,
9
9
  gitignore: true,
10
10
  ...options,
11
+ expandDirectories: true,
11
12
  // Explicitly ignore node_modules and lock files just in case
12
13
  ignore: [
13
14
  '**/.swellrc',
@@ -17,7 +18,6 @@ function globFiles(pattern, appPath, dirPath = '.', options = {}) {
17
18
  '**/yarn.lock',
18
19
  ...(options?.ignore || []),
19
20
  ],
20
- expandDirectories: true,
21
21
  });
22
22
  return filePaths;
23
23
  }
@@ -91,9 +91,9 @@ function isPathDirectory(path) {
91
91
  const stat = fs.statSync(path);
92
92
  return stat.isDirectory();
93
93
  }
94
- catch (error) {
94
+ catch {
95
95
  // Handle error (e.g., file not found)
96
96
  return false;
97
97
  }
98
98
  }
99
- export { allConfigDirsPaths, allConfigFilesPaths, allConfigFilesPathsByType, allConfigFilesInDir, allBaseFilesInDir, globAllFilesByPath, isPathDirectory, getAllConfigPaths, };
99
+ export { allBaseFilesInDir, allConfigDirsPaths, allConfigFilesInDir, allConfigFilesPaths, allConfigFilesPathsByType, getAllConfigPaths, globAllFilesByPath, isPathDirectory, };
@@ -1,4 +1,7 @@
1
1
  declare const env: any;
2
+ declare function setEnv(name: string, reviewBranch?: string): {
3
+ [key: string]: string;
4
+ };
2
5
  declare function ensureLoggedIn(storeId: string): Promise<any>;
3
6
  declare function get(key: string): any;
4
7
  declare function getAll(): any;
@@ -38,4 +41,4 @@ declare const config: {
38
41
  setStore: typeof setStore;
39
42
  setUser: typeof setUser;
40
43
  };
41
- export { config as default, env };
44
+ export { config as default, env, setEnv };
@@ -2,6 +2,10 @@ import Conf from 'conf';
2
2
  import Configstore from 'configstore';
3
3
  import { homedir } from 'node:os';
4
4
  import path from 'node:path';
5
+ import localEnv from '../env/local.js';
6
+ import prodEnv from '../env/production.js';
7
+ import reviewEnv from '../env/review.js';
8
+ import stagingEnv from '../env/staging.js';
5
9
  import style from './style.js';
6
10
  const configPath = process.env.NODE_ENV === 'test'
7
11
  ? path.resolve(process.cwd(), 'test', '.swell', 'config.json')
@@ -28,6 +32,36 @@ const env = new Conf({
28
32
  projectName: 'swell',
29
33
  projectSuffix: '',
30
34
  });
35
+ function setEnv(name, reviewBranch) {
36
+ let newEnv = {};
37
+ if (name.startsWith('prod')) {
38
+ newEnv = { ...prodEnv };
39
+ }
40
+ else if (name.startsWith('stag')) {
41
+ newEnv = { ...stagingEnv };
42
+ }
43
+ else if (name.startsWith('local')) {
44
+ newEnv = { ...localEnv };
45
+ }
46
+ else if (name.startsWith('rev') || name.startsWith('ra')) {
47
+ if (reviewBranch) {
48
+ const reviewAppEnv = { ...reviewEnv };
49
+ const reviewDomain = reviewBranch.replaceAll('/', '-');
50
+ for (const key of Object.keys(reviewAppEnv)) {
51
+ reviewAppEnv[key] = reviewAppEnv[key].replace('${REVIEW_DOMAIN}', reviewDomain);
52
+ }
53
+ newEnv = reviewAppEnv;
54
+ }
55
+ else {
56
+ throw new Error('Review environment requires a branch name.');
57
+ }
58
+ }
59
+ else {
60
+ throw new Error(`Invalid environment '${name}'. Should be one of 'prod', 'staging', 'review', or 'local'.`);
61
+ }
62
+ env.set(newEnv);
63
+ return newEnv;
64
+ }
31
65
  /**
32
66
  * Get specified attributes for given object.
33
67
  *
@@ -142,4 +176,4 @@ const config = {
142
176
  setStore,
143
177
  setUser,
144
178
  };
145
- export { config as default, env };
179
+ export { config as default, env, setEnv };
@@ -1,19 +1,18 @@
1
- /* eslint-disable no-template-curly-in-string */
1
+ import defaultEnv from '../env/production.js';
2
2
  import { env } from './config.js';
3
3
  // note: env values stored in ~/.swell/env.json
4
4
  // url for backend api calls
5
- export const API_BASE_URL = env.get('API_BASE_URL') || 'https://api.swell.store';
5
+ export const API_BASE_URL = env.get('API_BASE_URL') || defaultEnv.API_BASE_URL;
6
6
  // url for admin api calls
7
- export const ADMIN_API_BASE_URL = env.get('ADMIN_API_BASE_URL') || 'https://${STORE_ID}.swell.store/admin/api';
7
+ export const ADMIN_API_BASE_URL = env.get('ADMIN_API_BASE_URL') || defaultEnv.ADMIN_API_BASE_URL;
8
8
  // url host for admin login
9
- export const LOGIN_HOST = env.get('LOGIN_HOST') || 'https://${STORE_ID}.swell.store';
9
+ export const LOGIN_HOST = env.get('LOGIN_HOST') || defaultEnv.LOGIN_HOST;
10
10
  // url host for app frontend
11
- export const APP_PAGES_HOST = env.get('APP_PAGES_HOST') ||
12
- 'https://${STORE_ID}--${APP_ID}--${ENV}.swell.store';
11
+ export const APP_PAGES_HOST = env.get('APP_PAGES_HOST') || defaultEnv.APP_PAGES_HOST;
13
12
  // url host for storefront app frontend
14
13
  export const STOREFRONT_FRONTEND_HOST = env.get('STOREFRONT_FRONTEND_HOST') ||
15
- env.get('STOREFRONT_PAGES_HOST') ||
16
- 'https://${BRANCH_PREFIX}${STOREFRONT_SLUG}.swell.store';
14
+ env.get('STOREFRONT_PAGES_HOST') || // Deprecated
15
+ defaultEnv.STOREFRONT_FRONTEND_HOST;
17
16
  // helpers to get constants with replacements
18
17
  export function getAdminApiBaseUrl(storeId) {
19
18
  return ADMIN_API_BASE_URL.replace('${STORE_ID}', storeId);
@@ -5,8 +5,8 @@ const toFileName = (value) => dasherize(underscore(value.split('.')[0].replace('
5
5
  const toAppName = (value) => titleize(value)
6
6
  .replaceAll(/[_\s-:./-]+/g, ' ')
7
7
  .replaceAll(/([a-z])([A-Z])/g, '$1 $2')
8
- .replaceAll(/([0-9])([A-Z])/gi, '$1 $2')
9
- .replaceAll(/([A-Z])([0-9])/gi, '$1 $2');
8
+ .replaceAll(/(\d)([a-z])/gi, '$1 $2')
9
+ .replaceAll(/([a-z])(\d)/gi, '$1 $2');
10
10
  // Example: 'My App' => 'my_app'
11
11
  const toAppId = (value) => String(value || '')
12
12
  .replaceAll(/[^\s\w./:-]/g, '')
@@ -54,8 +54,10 @@ declare function selectEnvironmentId(message?: string): Promise<string>;
54
54
  * If there is no current store id, it will always be set as the default
55
55
  * without asking.
56
56
  *
57
- * @param currentStoreId - The ID of the default store
58
- * @param storeId - The ID of the store to set as the default
57
+ * @param storeParams -
58
+ * currentStoreId - The ID of the default store
59
+ * storeId - The ID of the store to set as the default
60
+ * @param force - True to force
59
61
  *
60
62
  * @returns void
61
63
  */
@@ -157,8 +157,10 @@ async function selectEnvironmentId(message) {
157
157
  * If there is no current store id, it will always be set as the default
158
158
  * without asking.
159
159
  *
160
- * @param currentStoreId - The ID of the default store
161
- * @param storeId - The ID of the store to set as the default
160
+ * @param storeParams -
161
+ * currentStoreId - The ID of the default store
162
+ * storeId - The ID of the store to set as the default
163
+ * @param force - True to force
162
164
  *
163
165
  * @returns void
164
166
  */
@@ -4,30 +4,21 @@ import { RemoteAppCommand } from './remote-app-command.js';
4
4
  type WatchFileEvent = 'change' | 'deleted' | 'new';
5
5
  export declare abstract class PushAppCommand extends RemoteAppCommand {
6
6
  frontendPath: string;
7
- watchingFiles: Array<string>;
8
- watchingChangeQueue: Array<any>;
9
- watchingChangeQueueRunning: boolean;
10
7
  logWatchChanges: boolean;
11
8
  onWatchChange?: ((appConfig?: AppConfig, result?: any) => void) | undefined;
12
- exec(command: string, onOutput?: (string: string) => false | any): Promise<void>;
13
- setWatchingFiles(): void;
14
- watchForChanges({ logChanges, syncAll, onChange, }?: {
15
- logChanges?: boolean | undefined;
16
- syncAll?: boolean | undefined;
17
- onChange?: (() => void) | undefined;
18
- }): Promise<void>;
9
+ watchingChangeQueue: Array<any>;
10
+ watchingChangeQueueRunning: boolean;
11
+ watchingFiles: Array<string>;
19
12
  watchListener: (eventType: string, filename: Buffer | null | string) => Promise<void>;
20
- handleWatchFileChange(configFile: string, configType: ConfigType, event: WatchFileEvent): Promise<void>;
21
- runWatchChangeQueue(): Promise<void>;
13
+ buildFrontend(projectType: FrontendProjectType): Promise<void>;
14
+ chooseAppToPull(query?: any): Promise<App>;
15
+ createAppStorefront(hasOtherStorefronts?: boolean): Promise<any>;
22
16
  deployAppFrontend(force?: boolean, log?: boolean): Promise<void>;
23
- getFrontendDeploymentHash(): string | undefined;
24
- getFrontendProjectType(required?: boolean): FrontendProjectType | null;
25
- ensureLoggedIn(): Promise<true | undefined>;
17
+ deployFrontend(projectType: FrontendProjectType): Promise<string>;
26
18
  ensureAppExists(file?: string, shouldCreate?: boolean): Promise<boolean>;
27
- private confirmRemoveInstalledApp;
28
- resolveAppPath(appId?: string, targetPath?: string): string;
29
- getAppStorefront(params?: {
30
- storefront_id?: string;
19
+ ensureLoggedIn(): Promise<true | undefined>;
20
+ exec(command: string, onOutput?: (string: string) => any | false): Promise<void>;
21
+ getAllAppStorefronts(params?: {
31
22
  type?: string;
32
23
  }): Promise<any>;
33
24
  getAllStorefronts(params?: {
@@ -35,19 +26,17 @@ export declare abstract class PushAppCommand extends RemoteAppCommand {
35
26
  theme_app_id?: string;
36
27
  type?: string;
37
28
  }): Promise<any>;
38
- getAllAppStorefronts(params?: {
29
+ getAppStorefront(params?: {
30
+ storefront_id?: string;
39
31
  type?: string;
40
32
  }): Promise<any>;
41
- saveCurrentStorefront(): void;
42
33
  getAppToPull(args: {
43
34
  appId?: string;
44
35
  targetPath?: string;
45
36
  }, shouldChoose?: boolean): Promise<App | undefined>;
46
37
  getExistingApp(appId: string): Promise<App>;
47
- getStorefrontToPush(flags?: {
48
- 'storefront-id'?: string;
49
- 'storefront-select'?: boolean;
50
- }): Promise<any>;
38
+ getFrontendDeploymentHash(): string | undefined;
39
+ getFrontendProjectType(required?: boolean): FrontendProjectType | null;
51
40
  getStorefrontToPull(args?: {
52
41
  appId?: string;
53
42
  targetPath?: string;
@@ -55,19 +44,30 @@ export declare abstract class PushAppCommand extends RemoteAppCommand {
55
44
  'storefront-id'?: string;
56
45
  'storefront-select'?: boolean;
57
46
  }): Promise<any>;
58
- chooseAppToPull(query?: any): Promise<App>;
59
- createAppStorefront(hasOtherStorefronts?: boolean): Promise<any>;
60
- logStorefrontConnected(): void;
47
+ getStorefrontToPush(flags?: {
48
+ 'storefront-id'?: string;
49
+ 'storefront-select'?: boolean;
50
+ }): Promise<any>;
51
+ handleWatchFileChange(configFile: string, configType: ConfigType, event: WatchFileEvent): Promise<void>;
52
+ logAppFrontendUrl(): void;
61
53
  logDashboardUrl(flags: {
62
54
  [flag: string]: any;
63
55
  }): void;
64
- pushFilePath(relativePath: string, force?: boolean): Promise<void>;
56
+ logStorefrontConnected(): void;
57
+ logStorefrontFrontendUrl(storefront?: any, branchId?: string): void;
65
58
  pushFile(relativePath: string): Promise<void>;
66
- deployFrontend(projectType: FrontendProjectType): Promise<string>;
67
- buildFrontend(projectType: FrontendProjectType): Promise<void>;
68
- wranglerDeployFrontend(projectType: FrontendProjectType): Promise<string>;
59
+ pushFilePath(relativePath: string, force?: boolean): Promise<void>;
60
+ resolveAppPath(appId?: string, targetPath?: string): string;
61
+ runWatchChangeQueue(): Promise<void>;
62
+ saveCurrentStorefront(): void;
63
+ setWatchingFiles(): void;
69
64
  updateFrontendDeployment(currentStore: string, projectType: FrontendProjectType, deploymentUrl: string, deploymentHash: string): Promise<void>;
70
- logAppFrontendUrl(): void;
71
- logStorefrontFrontendUrl(storefront?: any, branchId?: string): void;
65
+ watchForChanges({ logChanges, onChange, syncAll, }?: {
66
+ logChanges?: boolean | undefined;
67
+ onChange?: (() => void) | undefined;
68
+ syncAll?: boolean | undefined;
69
+ }): Promise<void>;
70
+ wranglerDeployFrontend(projectType: FrontendProjectType): Promise<string>;
71
+ private confirmRemoveInstalledApp;
72
72
  }
73
73
  export {};