@swell/cli 2.0.17 → 2.0.19

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.
@@ -79,9 +79,9 @@ behavior by using the --no-git-tag option.`;
79
79
  if (!(await this.ensureAppExists(undefined, false))) {
80
80
  return;
81
81
  }
82
- const remoteVersion = this.app.version;
82
+ const localVersion = this.app.version;
83
83
  if (amend) {
84
- const amendVersion = nextVersion || remoteVersion;
84
+ const amendVersion = nextVersion || localVersion;
85
85
  const appVersion = await this.getVersion(amendVersion);
86
86
  if (appVersion) {
87
87
  await this.updateVersion(amendVersion, {
@@ -93,21 +93,26 @@ behavior by using the --no-git-tag option.`;
93
93
  }
94
94
  return;
95
95
  }
96
+ const latestVersion = await this.getVersion();
97
+ const remoteVersion = latestVersion?.version;
98
+ // Suggest the next version if not provided
99
+ if (!nextVersion && semver.gt(localVersion, remoteVersion)) {
100
+ nextVersion = localVersion;
101
+ }
96
102
  // If the user didn't specify a version, show the latest one
97
103
  if (!nextVersion) {
98
- const latestVersion = await this.getVersion();
99
- if (latestVersion) {
100
- this.log(`${style.appConfigValue(this.app.name)} latest remote version is ${style.appConfigValue(latestVersion.version)}.`);
104
+ if (remoteVersion) {
105
+ this.log(`${style.appConfigValue(this.app.name)} latest remote version is ${style.appConfigValue(remoteVersion)}.`);
101
106
  }
102
107
  else {
103
- nextVersion = remoteVersion;
108
+ nextVersion = localVersion;
104
109
  if (!nextVersion) {
105
110
  this.error(`${style.appConfigValue(this.app.name)} has not been versioned yet.`);
106
111
  }
107
112
  }
108
113
  return;
109
114
  }
110
- nextVersion = this.validateAndComputeVersion(nextVersion, remoteVersion);
115
+ nextVersion = this.validateAndComputeVersion(nextVersion, localVersion);
111
116
  await this.pushAppConfigs();
112
117
  await this.deployAppFrontend(false, false);
113
118
  if (!message) {
@@ -175,15 +180,15 @@ behavior by using the --no-git-tag option.`;
175
180
  // tag the version in git
176
181
  await git.spawn(['tag', tag], { cwd: process.cwd() });
177
182
  }
178
- validateAndComputeVersion(nextVersion, remoteVersion) {
183
+ validateAndComputeVersion(nextVersion, localVersion) {
179
184
  let version = nextVersion;
180
185
  // compute the value of the next version and check if it's valid
181
186
  if (RELEASE_TYPES.includes(nextVersion)) {
182
187
  // increment the version
183
- version = semver.inc(remoteVersion, version);
188
+ version = semver.inc(localVersion, version);
184
189
  }
185
- if (semver.lt(version, remoteVersion)) {
186
- this.error(`Version ${version} must be greater than the current version ${remoteVersion}.`);
190
+ if (semver.lt(version, localVersion)) {
191
+ this.error(`Version ${version} must be greater than the current version ${localVersion}.`);
187
192
  }
188
193
  return version;
189
194
  }
@@ -194,24 +194,9 @@ export class RemoteAppCommand extends AppCommand {
194
194
  const appLabel = this.app.type === 'theme' ? 'theme' : 'app';
195
195
  let app = updateApp || {};
196
196
  if (!app.id) {
197
- // May already have a dev instance
198
- let existingDevApp;
199
- try {
200
- existingDevApp = await this.api.get({
201
- adminPath: `/apps/${this.swellConfig.store.id}`,
202
- });
203
- }
204
- catch {
205
- // noop
206
- }
207
197
  spinner.start(`Creating ${appLabel}...`);
208
- if (existingDevApp) {
209
- app = await this.handleRequestErrors(async () => this.api.put({ adminPath: `/apps/${existingDevApp.id}` }, { body }), () => spinner.fail('Error updating app.'));
210
- }
211
- else {
212
- app = await this.handleRequestErrors(async () => this.api.post({ adminPath: '/apps' }, { body }), () => spinner.fail('Error creating app.'));
213
- this.appCreated = true;
214
- }
198
+ app = await this.handleRequestErrors(async () => this.api.post({ adminPath: '/apps' }, { body }), () => spinner.fail('Error creating app.'));
199
+ this.appCreated = true;
215
200
  }
216
201
  else if (app.id) {
217
202
  spinner.start(`Updating ${appLabel}...`);
@@ -1891,5 +1891,5 @@
1891
1891
  ]
1892
1892
  }
1893
1893
  },
1894
- "version": "2.0.17"
1894
+ "version": "2.0.19"
1895
1895
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swell/cli",
3
- "version": "2.0.17",
3
+ "version": "2.0.19",
4
4
  "type": "module",
5
5
  "description": "Swell's command line interface/utility",
6
6
  "keywords": [