@swell/cli 2.0.1-alpha.5 → 2.0.1-alpha.7

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.
@@ -93,7 +93,8 @@ Without a store specified, install the app in the Live environment of the curren
93
93
  else {
94
94
  extraMessage = ` ${style.appConfigValue(this.app.name)} v${versionToInstall} on ${style.storeId(storeToInstall)} [${envToInstall ? envToInstall : 'live'}]`;
95
95
  }
96
- const shouldContinue = await this.confirmRemoveDevelopmentApp(storeToInstall);
96
+ const shouldContinue = existingVersion ||
97
+ (await this.confirmRemoveDevelopmentApp(storeToInstall));
97
98
  if (!shouldContinue) {
98
99
  return;
99
100
  }
@@ -148,6 +149,7 @@ Without a store specified, install the app in the Live environment of the curren
148
149
  query: { source_id: this.app.id },
149
150
  });
150
151
  if (existingSourcedApps.results[0]?.id) {
152
+ console.log(existingSourcedApps.results[0]);
151
153
  const continueInstall = await confirm({
152
154
  message: `${style.storeId(storeToInstall)} has a development version of ${style.appConfigValue(this.app.name)}. Do you want to replace it with an installed instance?`,
153
155
  default: false,
@@ -2,6 +2,9 @@ import { RemoteAppCommand } from '../../remote-app-command.js';
2
2
  export default class AppPush extends RemoteAppCommand {
3
3
  static description: string;
4
4
  static examples: string[];
5
+ static args: {
6
+ file: import("@oclif/core/lib/interfaces/parser.js").Arg<string | undefined, Record<string, unknown>>;
7
+ };
5
8
  static flags: {
6
9
  file: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
7
10
  };
@@ -1,5 +1,5 @@
1
1
  import { confirm } from '@inquirer/prompts';
2
- import { Flags } from '@oclif/core';
2
+ import { Flags, Args } from '@oclif/core';
3
3
  import * as path from 'node:path';
4
4
  import ora from 'ora';
5
5
  import { appConfigFileExists } from '../../lib/app-config.js';
@@ -26,6 +26,13 @@ ${Object.values(ConfigPaths)
26
26
  'swell app push -f content',
27
27
  'swell app push -f models/products.json',
28
28
  ];
29
+ static args = {
30
+ file: Args.string({
31
+ char: 'f',
32
+ description: 'relative path to a configuration file or directory to push',
33
+ }),
34
+ };
35
+ // Deprecating the flags in favor of args
29
36
  static flags = {
30
37
  file: Flags.string({
31
38
  char: 'f',
@@ -37,8 +44,10 @@ ${Object.values(ConfigPaths)
37
44
  };
38
45
  static summary = 'Push configuration files to your Swell app.';
39
46
  async run() {
40
- const { flags } = await this.parse(AppPush);
41
- const { file } = flags;
47
+ const { args, flags } = await this.parse(AppPush);
48
+ const { file: fileArg } = args;
49
+ const { file: fileFlag } = flags;
50
+ const file = fileArg || fileFlag;
42
51
  const currentStore = swellConfig.getDefaultStore();
43
52
  this.api.setStoreEnv(currentStore, 'test');
44
53
  this.app = await this.getAppWithConfig('', false);
@@ -18,6 +18,7 @@ export default class Logs extends SwellCommand {
18
18
  static summary: string;
19
19
  private output;
20
20
  run(): Promise<void>;
21
+ __run(): Promise<void>;
21
22
  private getLogs;
22
23
  private getLogsAndWriteToStream;
23
24
  }
@@ -1,4 +1,5 @@
1
1
  import { Flags } from '@oclif/core';
2
+ import ora from 'ora';
2
3
  import { LineOutput, LoggedItem, TableOutput } from '../lib/logs/index.js';
3
4
  import { SwellCommand } from '../swell-command.js';
4
5
  // the columns available to display in the table
@@ -162,6 +163,10 @@ export default class Logs extends SwellCommand {
162
163
  static summary = 'Output or stream store logs to the terminal.';
163
164
  output;
164
165
  async run() {
166
+ const spinner = ora();
167
+ spinner.fail('This command is temporarily disabled. Check back soon.');
168
+ }
169
+ async __run() {
165
170
  const { flags } = await this.parse(Logs);
166
171
  // indentify the columns to display
167
172
  const columns = flags.columns.split(',');
@@ -68,9 +68,12 @@ class AppConfig {
68
68
  }
69
69
  }
70
70
  async postData() {
71
- if (!this.localPath || !this.fileData) {
71
+ if (!this.localPath) {
72
72
  throw new Error('Missing local config path');
73
73
  }
74
+ if (!this.fileData) {
75
+ return;
76
+ }
74
77
  if (this.localPath.endsWith('.json')) {
75
78
  try {
76
79
  this.values = JSON.parse(this.fileData);
@@ -22,6 +22,9 @@ export async function bundleFunction(filePath) {
22
22
  ? line.replace('module.exports', 'var moduleExports')
23
23
  : line)
24
24
  .join('\n');
25
+ // Remove comments with to get a unique hash in the API
26
+ // Because esbuild puts the file name as a comment
27
+ code = code.replace(/^[\n]?\/\/.*/gm, '');
25
28
  // eslint-disable-next-line no-new-func
26
29
  const evalFn = new Function(`${code}\nreturn { ...moduleExports }`);
27
30
  const { config, ...moduleExports } = evalFn();
@@ -228,6 +228,10 @@ export class RemoteAppCommand extends AppCommand {
228
228
  spinner.start(`Pushing ${pathDesc}`);
229
229
  try {
230
230
  postData = await appConfig.postData();
231
+ if (!postData) {
232
+ spinner.stop();
233
+ return;
234
+ }
231
235
  }
232
236
  catch (error) {
233
237
  if (error instanceof IgnoringFileError) {
@@ -452,7 +452,12 @@
452
452
  },
453
453
  "app:push": {
454
454
  "aliases": [],
455
- "args": {},
455
+ "args": {
456
+ "file": {
457
+ "description": "relative path to a configuration file or directory to push",
458
+ "name": "file"
459
+ }
460
+ },
456
461
  "description": "Push all app configurations, a specific file, or a specific configuration\ntype to an app in your store's test environment. If the app does not exist yet,\nit will be created and its global ID saved to a .swellrc file.\n\n- If no file is specified, all configuration files will be pushed to the store.\n This includes the app icon (assets/icon.png) and swell.json.\n- If a file is specified, only that file will be pushed to the store.\n- If a directory is specified, only files in that directory will be pushed.\n\nApp configuration directories:\nassets/\ncontent/\nfunctions/\nmodels/\nnotifications/\nsettings/\nwebhooks/",
457
462
  "examples": [
458
463
  "swell app push",
@@ -1081,5 +1086,5 @@
1081
1086
  ]
1082
1087
  }
1083
1088
  },
1084
- "version": "2.0.1-alpha.5"
1089
+ "version": "2.0.1-alpha.7"
1085
1090
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swell/cli",
3
- "version": "2.0.1-alpha.5",
3
+ "version": "2.0.1-alpha.7",
4
4
  "type": "module",
5
5
  "description": "Swell's command line interface/utility",
6
6
  "keywords": [