@swell/cli 2.0.1-alpha.13 → 2.0.1-alpha.17

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 (91) hide show
  1. package/dist/app-command.d.ts +1 -1
  2. package/dist/app-command.js +8 -8
  3. package/dist/commands/app/dev.d.ts +18 -0
  4. package/dist/commands/app/dev.js +31 -0
  5. package/dist/commands/app/frontend/deploy.d.ts +17 -0
  6. package/dist/commands/app/frontend/deploy.js +44 -0
  7. package/dist/commands/app/frontend/dev.d.ts +21 -0
  8. package/dist/commands/app/frontend/dev.js +111 -0
  9. package/dist/commands/app/info.js +15 -8
  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 +4 -4
  13. package/dist/commands/app/install.js +37 -42
  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 +11 -14
  17. package/dist/commands/app/push.js +71 -143
  18. package/dist/commands/app/release.d.ts +13 -0
  19. package/dist/commands/app/release.js +150 -0
  20. package/dist/commands/app/version.d.ts +7 -6
  21. package/dist/commands/app/version.js +64 -43
  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 +150 -144
  26. package/dist/commands/create/content.d.ts +2 -2
  27. package/dist/commands/create/content.js +10 -10
  28. package/dist/commands/create/frontend.d.ts +12 -0
  29. package/dist/commands/create/frontend.js +41 -0
  30. package/dist/commands/create/function.d.ts +3 -3
  31. package/dist/commands/create/function.js +22 -22
  32. package/dist/commands/create/model.d.ts +2 -2
  33. package/dist/commands/create/model.js +11 -11
  34. package/dist/commands/create/notification.d.ts +4 -4
  35. package/dist/commands/create/notification.js +38 -40
  36. package/dist/commands/login.d.ts +1 -1
  37. package/dist/commands/login.js +12 -9
  38. package/dist/commands/logs.js +2 -1
  39. package/dist/commands/theme/dev.d.ts +23 -0
  40. package/dist/commands/theme/dev.js +167 -0
  41. package/dist/commands/theme/init.d.ts +9 -0
  42. package/dist/commands/theme/init.js +15 -0
  43. package/dist/commands/theme/pull.d.ts +20 -0
  44. package/dist/commands/theme/pull.js +65 -0
  45. package/dist/commands/theme/push.d.ts +19 -0
  46. package/dist/commands/theme/push.js +92 -0
  47. package/dist/create-app-command.d.ts +20 -0
  48. package/dist/create-app-command.js +254 -0
  49. package/dist/create-collection-command.d.ts +9 -9
  50. package/dist/create-collection-command.js +23 -23
  51. package/dist/{create-command.d.ts → create-config-command.d.ts} +1 -1
  52. package/dist/{create-command.js → create-config-command.js} +9 -7
  53. package/dist/lib/api.d.ts +6 -4
  54. package/dist/lib/api.js +58 -29
  55. package/dist/lib/app-config.d.ts +13 -5
  56. package/dist/lib/app-config.js +60 -23
  57. package/dist/lib/apps/app-config.d.ts +22 -8
  58. package/dist/lib/apps/app-config.js +202 -68
  59. package/dist/lib/apps/index.d.ts +93 -13
  60. package/dist/lib/apps/index.js +150 -50
  61. package/dist/lib/apps/paths.d.ts +14 -7
  62. package/dist/lib/apps/paths.js +73 -28
  63. package/dist/lib/bundle.js +4 -5
  64. package/dist/lib/config.d.ts +5 -1
  65. package/dist/lib/config.js +14 -0
  66. package/dist/lib/constants.d.ts +5 -0
  67. package/dist/lib/constants.js +22 -3
  68. package/dist/lib/create/content.d.ts +2 -2
  69. package/dist/lib/create/content.js +1 -1
  70. package/dist/lib/create/function.d.ts +2 -2
  71. package/dist/lib/create/function.js +2 -2
  72. package/dist/lib/create/index.d.ts +1 -1
  73. package/dist/lib/create/index.js +11 -7
  74. package/dist/lib/create/model.d.ts +2 -2
  75. package/dist/lib/create/notification.d.ts +2 -2
  76. package/dist/lib/info.js +2 -2
  77. package/dist/lib/sessions.js +2 -2
  78. package/dist/lib/stores.d.ts +5 -2
  79. package/dist/lib/stores.js +9 -6
  80. package/dist/lib/style.d.ts +2 -0
  81. package/dist/lib/style.js +2 -0
  82. package/dist/lib/swell-function-wrapper.d.ts +2 -2
  83. package/dist/lib/swell-function-wrapper.js +2 -2
  84. package/dist/push-app-command.d.ts +73 -0
  85. package/dist/push-app-command.js +765 -0
  86. package/dist/remote-app-command.d.ts +35 -9
  87. package/dist/remote-app-command.js +436 -164
  88. package/oclif.manifest.json +841 -125
  89. package/package.json +13 -1
  90. package/dist/commands/app/_pull.d.ts +0 -8
  91. package/dist/commands/app/_pull.js +0 -45
@@ -10,4 +10,4 @@ declare const toFunctionFileName: (value: string) => string;
10
10
  declare const toCollectionName: (value: string) => string;
11
11
  declare const toCollectionLabel: (value: string) => string;
12
12
  declare const toNotificationLabel: (value: string) => string;
13
- export { CreateFileParams, toFileName, toAppName, toAppId, toFunctionFileName, toCollectionName, toCollectionLabel, toNotificationLabel, };
13
+ export { CreateFileParams, toAppId, toAppName, toCollectionLabel, toCollectionName, toFileName, toFunctionFileName, toNotificationLabel, };
@@ -1,14 +1,18 @@
1
- import { dasherize, pluralize, underscore, titleize } from 'inflection';
1
+ import { dasherize, pluralize, titleize, underscore } from 'inflection';
2
2
  // Example: 'My Thing' => 'my-thing'
3
3
  const toFileName = (value) => dasherize(underscore(value.split('.')[0].replace(' ', '_'))).toLowerCase();
4
4
  // Example: 'my-things' => 'My Things'
5
- const toAppName = (value) => pluralize(titleize(value).replace('-', ' '));
5
+ const toAppName = (value) => titleize(value)
6
+ .replaceAll(/[_\s-:./-]+/g, ' ')
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');
6
10
  // Example: 'My App' => 'my_app'
7
11
  const toAppId = (value) => String(value || '')
8
- .replace(/[^a-zA-Z0-9\-_\s:\.\/]/g, '')
9
- .replace(/[_\s-:\.\/]+/g, '_')
10
- .replace(/^[_]+|[_]+$/g, '')
11
- .replace(/([a-z])([A-Z])/g, '$1_$2')
12
+ .replaceAll(/[^\s\w./:-]/g, '')
13
+ .replaceAll(/[_\s-:./]+/g, '_')
14
+ .replaceAll(/^_+|_+$/g, '')
15
+ .replaceAll(/([a-z])([A-Z])/g, '$1_$2')
12
16
  .toLowerCase();
13
17
  // Example: 'My Thing' => 'my-thing'
14
18
  // And: 'myThing' => 'myThing'
@@ -19,4 +23,4 @@ const toCollectionName = (value) => pluralize(value.replaceAll(/[^A-Za-z]/g, '-'
19
23
  const toCollectionLabel = (value) => pluralize(titleize(value).replace('-', ' '));
20
24
  // Example: 'order-receipt' => 'Order Receipt'
21
25
  const toNotificationLabel = (value) => titleize(value).replace('-', ' ');
22
- export { toFileName, toAppName, toAppId, toFunctionFileName, toCollectionName, toCollectionLabel, toNotificationLabel, };
26
+ export { toAppId, toAppName, toCollectionLabel, toCollectionName, toFileName, toFunctionFileName, toNotificationLabel, };
@@ -1,9 +1,9 @@
1
1
  interface CreateModelFileBody {
2
- label?: string;
3
2
  collection?: string;
4
3
  description?: string;
5
- fields?: ModelFieldResponse;
6
4
  events?: ModelEventObject;
5
+ fields?: ModelFieldResponse;
6
+ label?: string;
7
7
  }
8
8
  interface ModelEventObject {
9
9
  types?: ModelEvent[];
@@ -1,11 +1,11 @@
1
1
  interface WriteNotificationsFileParams {
2
+ admin?: boolean;
2
3
  description: string;
3
4
  event: string;
4
5
  model: string;
5
6
  name: string;
6
- subject: string;
7
- admin?: boolean;
8
7
  once?: boolean;
8
+ subject: string;
9
9
  }
10
10
  interface CreateNotificationFileBody {
11
11
  admin?: boolean;
package/dist/lib/info.js CHANGED
@@ -20,7 +20,7 @@ export class FieldDefinitions {
20
20
  get client() {
21
21
  return {
22
22
  label: 'Test store',
23
- transform: (client) => `${client.name} (${style.storeId(client.id)})`,
23
+ transform: (client) => client && `${client.name} (${style.storeId(client.id)})`,
24
24
  };
25
25
  }
26
26
  get dateCreated() {
@@ -57,7 +57,7 @@ export class FieldDefinitions {
57
57
  label: 'Version',
58
58
  transform: (_version) => {
59
59
  if (this.versions.length === 0) {
60
- return 'N/A';
60
+ return this.app.version || 'N/A';
61
61
  }
62
62
  return [
63
63
  style.appConfigValue(this.versions[0].version),
@@ -20,7 +20,6 @@ function createServer(onSessionId, storeId) {
20
20
  // the spinner is used to show progress while waiting for the browser
21
21
  const spinner = ux.action;
22
22
  serverForLogin({
23
- storeId,
24
23
  onPost(req) {
25
24
  // we received the session id from the browser so we can move on
26
25
  const sessionId = req.headers['x-session'];
@@ -37,6 +36,7 @@ function createServer(onSessionId, storeId) {
37
36
  ].join(' '));
38
37
  await open(loginUrl);
39
38
  },
39
+ storeId,
40
40
  });
41
41
  }
42
42
  /**
@@ -52,7 +52,7 @@ function createServer(onSessionId, storeId) {
52
52
  * from the browser
53
53
  * @returns void
54
54
  */
55
- function serverForLogin({ storeId, onPost, onStart, }) {
55
+ function serverForLogin({ onPost, onStart, storeId, }) {
56
56
  // flag to track if the POST and GET requests have been handled
57
57
  // we only want to handle them once
58
58
  let postHandled = false;
@@ -35,6 +35,7 @@ declare function selectStoreId({ authorizations, currentStoreId, force, }: {
35
35
  * Select the store to switch to from a CLI prompt from the list of
36
36
  * already logged in stores.
37
37
  *
38
+ * @param message Store selection message
38
39
  * @returns The store ID to switch to
39
40
  * @throws CLIError - If there are no stores to switch to
40
41
  */
@@ -42,6 +43,8 @@ declare function selectLoggedInStoreId(message?: string): Promise<string>;
42
43
  /**
43
44
  * Select an environment.
44
45
  *
46
+ * @param message Environment selection message
47
+ * @returns Environment to switch to
45
48
  * @throws CLIError - If there are no stores to switch to
46
49
  */
47
50
  declare function selectEnvironmentId(message?: string): Promise<string>;
@@ -59,5 +62,5 @@ declare function selectEnvironmentId(message?: string): Promise<string>;
59
62
  declare function modifyDefaultStore({ currentStoreId, storeId, }: {
60
63
  currentStoreId: string;
61
64
  storeId: string;
62
- }): Promise<void>;
63
- export { modifyDefaultStore, selectLoggedInStoreId, selectStoreId, selectEnvironmentId, showStores, };
65
+ }, force?: boolean): Promise<void>;
66
+ export { modifyDefaultStore, selectEnvironmentId, selectLoggedInStoreId, selectStoreId, showStores, };
@@ -101,6 +101,7 @@ async function selectStoreId({ authorizations, currentStoreId, force = false, })
101
101
  * Select the store to switch to from a CLI prompt from the list of
102
102
  * already logged in stores.
103
103
  *
104
+ * @param message Store selection message
104
105
  * @returns The store ID to switch to
105
106
  * @throws CLIError - If there are no stores to switch to
106
107
  */
@@ -123,14 +124,16 @@ async function selectLoggedInStoreId(message) {
123
124
  new Separator(),
124
125
  { name: 'Login to another account', value: '' },
125
126
  ],
127
+ loop: false,
126
128
  message: message || 'Which store do you want to switch to?',
127
129
  pageSize: 25,
128
- loop: false,
129
130
  });
130
131
  }
131
132
  /**
132
133
  * Select an environment.
133
134
  *
135
+ * @param message Environment selection message
136
+ * @returns Environment to switch to
134
137
  * @throws CLIError - If there are no stores to switch to
135
138
  */
136
139
  async function selectEnvironmentId(message) {
@@ -145,7 +148,7 @@ async function selectEnvironmentId(message) {
145
148
  value: 'test',
146
149
  },
147
150
  ],
148
- message: message || 'Which envoronment?',
151
+ message: message || 'Which environment?',
149
152
  });
150
153
  }
151
154
  /**
@@ -159,15 +162,15 @@ async function selectEnvironmentId(message) {
159
162
  *
160
163
  * @returns void
161
164
  */
162
- async function modifyDefaultStore({ currentStoreId, storeId, }) {
165
+ async function modifyDefaultStore({ currentStoreId, storeId, }, force = false) {
163
166
  let modifyDefault = false;
164
- if (currentStoreId && currentStoreId !== storeId) {
167
+ if (!force && currentStoreId && currentStoreId !== storeId) {
165
168
  modifyDefault = await confirm({
166
169
  message: `Do you want to make ${style.storeId(storeId)} your default store?`,
167
170
  });
168
171
  }
169
- if (!currentStoreId || modifyDefault) {
172
+ if (force || !currentStoreId || modifyDefault) {
170
173
  config.setDefaultStore(storeId);
171
174
  }
172
175
  }
173
- export { modifyDefaultStore, selectLoggedInStoreId, selectStoreId, selectEnvironmentId, showStores, };
176
+ export { modifyDefaultStore, selectEnvironmentId, selectLoggedInStoreId, selectStoreId, showStores, };
@@ -5,9 +5,11 @@ declare const _default: {
5
5
  link: import("chalk").ChalkInstance;
6
6
  path: import("chalk").ChalkInstance;
7
7
  dim: import("chalk").ChalkInstance;
8
+ strike: import("chalk").ChalkInstance;
8
9
  command: import("chalk").ChalkInstance;
9
10
  storeId: import("chalk").ChalkInstance;
10
11
  currentUser: import("chalk").ChalkInstance;
12
+ appName: import("chalk").ChalkInstance;
11
13
  appEnvLive: import("chalk").ChalkInstance;
12
14
  appEnv: import("chalk").ChalkInstance;
13
15
  appConfigName: import("chalk").ChalkInstance;
package/dist/lib/style.js CHANGED
@@ -7,11 +7,13 @@ export default {
7
7
  link: chalk.blueBright.underline,
8
8
  path: chalk.underline,
9
9
  dim: chalk.dim,
10
+ strike: chalk.strikethrough,
10
11
  // styles for consistent output of some elements
11
12
  command: chalk.magenta.bold,
12
13
  storeId: chalk.yellow,
13
14
  currentUser: chalk.blueBright.underline,
14
15
  // apps
16
+ appName: chalk.yellow,
15
17
  appEnvLive: chalk.magenta,
16
18
  appEnv: chalk.yellow,
17
19
  appConfigName: chalk.yellow,
@@ -84,11 +84,11 @@ declare class SwellRequest {
84
84
  ingestLogs(response: any): Promise<void>;
85
85
  /**
86
86
  * Merge values into app data for the current request.
87
- * @param {object|string|undefined} idOrValues string to indicate app ID, or values to merge
87
+ * @param {object|string} idOrValues string to indicate app ID, or values to merge
88
88
  * @param {object|undefined} values values to merge into app data
89
89
  * @returns {object|undefined} existing app data merged with values if passed
90
90
  */
91
- appValues(idOrValues?: object | string | undefined, values?: object | undefined): object | undefined;
91
+ appValues(idOrValues: object | string, values?: object | undefined): object | undefined;
92
92
  }
93
93
  /**
94
94
  * Class representing the Swell backend API.
@@ -182,11 +182,11 @@ class SwellRequest {
182
182
  }
183
183
  /**
184
184
  * Merge values into app data for the current request.
185
- * @param {object|string|undefined} idOrValues string to indicate app ID, or values to merge
185
+ * @param {object|string} idOrValues string to indicate app ID, or values to merge
186
186
  * @param {object|undefined} values values to merge into app data
187
187
  * @returns {object|undefined} existing app data merged with values if passed
188
188
  */
189
- appValues(idOrValues = undefined, values = undefined) {
189
+ appValues(idOrValues, values = undefined) {
190
190
  const appId = typeof idOrValues === 'string' ? appIdOrValues : this.appId;
191
191
  const appValues = typeof idOrValues === 'string' ? values : idOrValues;
192
192
  if (!appId || !isOrdinaryObject(appValues)) {
@@ -0,0 +1,73 @@
1
+ /// <reference types="node" />
2
+ import { App, AppConfig, ConfigType, FrontendProjectType } from './lib/apps/index.js';
3
+ import { RemoteAppCommand } from './remote-app-command.js';
4
+ type WatchFileEvent = 'change' | 'deleted' | 'new';
5
+ export declare abstract class PushAppCommand extends RemoteAppCommand {
6
+ frontendPath: string;
7
+ watchingFiles: Array<string>;
8
+ watchingChangeQueue: Array<any>;
9
+ watchingChangeQueueRunning: boolean;
10
+ logWatchChanges: boolean;
11
+ 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>;
19
+ watchListener: (eventType: string, filename: Buffer | null | string) => Promise<void>;
20
+ handleWatchFileChange(configFile: string, configType: ConfigType, event: WatchFileEvent): Promise<void>;
21
+ runWatchChangeQueue(): Promise<void>;
22
+ deployAppFrontend(force?: boolean, log?: boolean): Promise<void>;
23
+ getFrontendDeploymentHash(): string | undefined;
24
+ getFrontendProjectType(required?: boolean): FrontendProjectType | null;
25
+ ensureLoggedIn(): Promise<true | undefined>;
26
+ ensureAppExists(file?: string, shouldCreate?: boolean): Promise<boolean>;
27
+ private confirmRemoveInstalledApp;
28
+ resolveAppPath(appId?: string, targetPath?: string): string;
29
+ getAppStorefront(params?: {
30
+ storefront_id?: string;
31
+ type?: string;
32
+ }): Promise<any>;
33
+ getAllStorefronts(params?: {
34
+ app_id?: string;
35
+ theme_app_id?: string;
36
+ type?: string;
37
+ }): Promise<any>;
38
+ getAllAppStorefronts(params?: {
39
+ type?: string;
40
+ }): Promise<any>;
41
+ saveCurrentStorefront(): void;
42
+ getAppToPull(args: {
43
+ appId?: string;
44
+ targetPath?: string;
45
+ }, shouldChoose?: boolean): Promise<App | undefined>;
46
+ getExistingApp(appId: string): Promise<App>;
47
+ getStorefrontToPush(flags?: {
48
+ 'storefront-id'?: string;
49
+ 'storefront-select'?: boolean;
50
+ }): Promise<any>;
51
+ getStorefrontToPull(args?: {
52
+ appId?: string;
53
+ targetPath?: string;
54
+ }, flags?: {
55
+ 'storefront-id'?: string;
56
+ 'storefront-select'?: boolean;
57
+ }): Promise<any>;
58
+ chooseAppToPull(query?: any): Promise<App>;
59
+ createAppStorefront(hasOtherStorefronts?: boolean): Promise<any>;
60
+ logStorefrontConnected(): void;
61
+ logDashboardUrl(flags: {
62
+ [flag: string]: any;
63
+ }): void;
64
+ pushFilePath(relativePath: string, force?: boolean): Promise<void>;
65
+ pushFile(relativePath: string): Promise<void>;
66
+ deployFrontend(projectType: FrontendProjectType): Promise<string>;
67
+ buildFrontend(projectType: FrontendProjectType): Promise<void>;
68
+ wranglerDeployFrontend(projectType: FrontendProjectType): Promise<string>;
69
+ updateFrontendDeployment(currentStore: string, projectType: FrontendProjectType, deploymentUrl: string, deploymentHash: string): Promise<void>;
70
+ logAppFrontendUrl(): void;
71
+ logStorefrontFrontendUrl(storefront?: any, branchId?: string): void;
72
+ }
73
+ export {};