@swell/cli 2.1.0 → 2.2.0
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.
- package/dist/commands/api/delete.d.ts +15 -0
- package/dist/commands/api/delete.js +26 -0
- package/dist/commands/api/get.d.ts +15 -0
- package/dist/commands/api/get.js +31 -0
- package/dist/commands/api/index.d.ts +7 -0
- package/dist/commands/api/index.js +16 -0
- package/dist/commands/api/post.d.ts +16 -0
- package/dist/commands/api/post.js +33 -0
- package/dist/commands/api/put.d.ts +16 -0
- package/dist/commands/api/put.js +33 -0
- package/dist/commands/app/dev.d.ts +9 -9
- package/dist/commands/app/dev.js +158 -136
- package/dist/commands/app/frontend/dev.d.ts +1 -1
- package/dist/commands/app/frontend/dev.js +84 -78
- package/dist/commands/app/install.js +3 -3
- package/dist/commands/app/pull.d.ts +1 -1
- package/dist/commands/app/pull.js +6 -6
- package/dist/commands/app/push.d.ts +3 -3
- package/dist/commands/app/push.js +8 -6
- package/dist/commands/app/release.d.ts +1 -1
- package/dist/commands/app/release.js +1 -1
- package/dist/commands/app/version.d.ts +1 -1
- package/dist/commands/app/version.js +5 -3
- package/dist/commands/create/app.d.ts +10 -2
- package/dist/commands/create/app.js +226 -57
- package/dist/commands/create/content.d.ts +4 -0
- package/dist/commands/create/content.js +83 -15
- package/dist/commands/create/function.js +27 -5
- package/dist/commands/create/model.d.ts +4 -0
- package/dist/commands/create/model.js +120 -25
- package/dist/commands/inspect/content.d.ts +25 -0
- package/dist/commands/inspect/content.js +159 -0
- package/dist/commands/inspect/index.d.ts +7 -0
- package/dist/commands/inspect/index.js +16 -0
- package/dist/commands/inspect/models.d.ts +27 -0
- package/dist/commands/inspect/models.js +197 -0
- package/dist/commands/schema.d.ts +27 -0
- package/dist/commands/schema.js +231 -0
- package/dist/commands/theme/dev.d.ts +1 -1
- package/dist/commands/theme/dev.js +2 -2
- package/dist/commands/theme/init.d.ts +1 -1
- package/dist/commands/theme/init.js +1 -1
- package/dist/commands/theme/pull.d.ts +2 -2
- package/dist/commands/theme/pull.js +2 -2
- package/dist/commands/theme/push.d.ts +1 -1
- package/dist/commands/theme/push.js +1 -1
- package/dist/create-app-command.d.ts +12 -2
- package/dist/create-app-command.js +103 -80
- package/dist/create-collection-command.js +4 -1
- package/dist/create-config-command.js +4 -0
- package/dist/env/local.d.ts +1 -0
- package/dist/env/local.js +1 -0
- package/dist/env/production.d.ts +1 -0
- package/dist/env/production.js +1 -0
- package/dist/env/review.d.ts +1 -0
- package/dist/env/review.js +1 -0
- package/dist/env/staging.d.ts +1 -0
- package/dist/env/staging.js +1 -0
- package/dist/lib/api.d.ts +16 -5
- package/dist/lib/api.js +67 -25
- package/dist/lib/app-config.js +1 -0
- package/dist/lib/apps/index.d.ts +2 -0
- package/dist/lib/apps/index.js +20 -15
- package/dist/lib/config.d.ts +1 -1
- package/dist/lib/constants.d.ts +1 -0
- package/dist/lib/constants.js +1 -0
- package/dist/lib/create/content.d.ts +5 -1
- package/dist/lib/create/content.js +8 -1
- package/dist/lib/create/function.d.ts +2 -1
- package/dist/lib/create/function.js +7 -3
- package/dist/lib/create/model.d.ts +1 -0
- package/dist/lib/create/schemas.d.ts +6 -0
- package/dist/lib/create/schemas.js +6 -0
- package/dist/lib/sessions.js +4 -3
- package/dist/lib/style.js +0 -1
- package/dist/lib/theme-sync.d.ts +6 -6
- package/dist/lib/theme-sync.js +49 -39
- package/dist/push-app-command.d.ts +7 -7
- package/dist/push-app-command.js +38 -36
- package/dist/remote-app-command.d.ts +1 -1
- package/dist/remote-app-command.js +4 -2
- package/dist/swell-api-command.d.ts +13 -0
- package/dist/swell-api-command.js +75 -0
- package/dist/swell-command.d.ts +1 -1
- package/dist/swell-command.js +9 -9
- package/package.json +8 -1
- package/oclif.manifest.json +0 -1936
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HttpMethod } from './lib/api.js';
|
|
2
|
+
import { SwellCommand } from './swell-command.js';
|
|
3
|
+
export declare abstract class SwellApiCommand extends SwellCommand {
|
|
4
|
+
protected abstract get method(): HttpMethod;
|
|
5
|
+
protected request(command: typeof SwellApiCommand, requestOptions?: Api.RequestOptions): Promise<void>;
|
|
6
|
+
protected catch(error: Error): Promise<any>;
|
|
7
|
+
private parseCommand;
|
|
8
|
+
private processBody;
|
|
9
|
+
private isFilePath;
|
|
10
|
+
private handleResponse;
|
|
11
|
+
private onSuccess;
|
|
12
|
+
private onError;
|
|
13
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { FetchError } from 'node-fetch';
|
|
4
|
+
import { SwellCommand } from './swell-command.js';
|
|
5
|
+
export class SwellApiCommand extends SwellCommand {
|
|
6
|
+
async request(command, requestOptions = {}) {
|
|
7
|
+
const { paths, options } = await this.parseCommand(command);
|
|
8
|
+
const response = await this.api[this.method](paths, {
|
|
9
|
+
rawResponse: true,
|
|
10
|
+
...options,
|
|
11
|
+
...requestOptions,
|
|
12
|
+
});
|
|
13
|
+
await this.handleResponse(response);
|
|
14
|
+
}
|
|
15
|
+
async catch(error) {
|
|
16
|
+
if (error instanceof FetchError) {
|
|
17
|
+
const message = `Could not connect to Swell API. Please try again later: ${error.message}`;
|
|
18
|
+
return this.onError(message, { exit: 2, code: error.code });
|
|
19
|
+
}
|
|
20
|
+
return this.onError(error.message, { exit: 1 });
|
|
21
|
+
}
|
|
22
|
+
async parseCommand(options, argv) {
|
|
23
|
+
const parsedInput = await super.parse(options, argv);
|
|
24
|
+
const { args, flags } = parsedInput;
|
|
25
|
+
const { path } = args;
|
|
26
|
+
const { live, body } = flags;
|
|
27
|
+
if (!live) {
|
|
28
|
+
await this.api.setEnv('test');
|
|
29
|
+
}
|
|
30
|
+
if (!path.startsWith('/')) {
|
|
31
|
+
throw new Error('Path must start with a forward slash (/)');
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
...parsedInput,
|
|
35
|
+
paths: { adminPath: `/data${path}` },
|
|
36
|
+
options: {
|
|
37
|
+
body: await this.processBody(body),
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
async processBody(body) {
|
|
42
|
+
if (!body) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const bodyData = this.isFilePath(body)
|
|
46
|
+
? await fs.promises.readFile(path.resolve(body), 'utf8')
|
|
47
|
+
: body;
|
|
48
|
+
return JSON.parse(bodyData);
|
|
49
|
+
}
|
|
50
|
+
isFilePath(filePath) {
|
|
51
|
+
return (path.isAbsolute(filePath) ||
|
|
52
|
+
filePath.startsWith('./') ||
|
|
53
|
+
filePath.startsWith('../'));
|
|
54
|
+
}
|
|
55
|
+
async handleResponse(response) {
|
|
56
|
+
const responseText = await response.text();
|
|
57
|
+
if (responseText.length <= 2) {
|
|
58
|
+
throw new Error('Not found');
|
|
59
|
+
}
|
|
60
|
+
const result = JSON.parse(responseText);
|
|
61
|
+
if (result.error || result.errors || !response.ok) {
|
|
62
|
+
throw new Error(responseText);
|
|
63
|
+
}
|
|
64
|
+
this.onSuccess(result);
|
|
65
|
+
}
|
|
66
|
+
onSuccess(result) {
|
|
67
|
+
this.log(JSON.stringify(result, null, 2));
|
|
68
|
+
}
|
|
69
|
+
onError(message, { code, exit }) {
|
|
70
|
+
this.error(message, {
|
|
71
|
+
code,
|
|
72
|
+
exit,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
package/dist/swell-command.d.ts
CHANGED
|
@@ -14,8 +14,8 @@ export declare abstract class SwellCommand extends Command {
|
|
|
14
14
|
api: Api;
|
|
15
15
|
requiresAuth: boolean;
|
|
16
16
|
constructor(argv: string[], config: Config);
|
|
17
|
-
catch(error: any): Promise<void>;
|
|
18
17
|
debugJson(...args: any[]): void;
|
|
19
18
|
logError(message: string): void;
|
|
20
19
|
logSuccess(message: string): void;
|
|
20
|
+
protected catch(error: any): Promise<void>;
|
|
21
21
|
}
|
package/dist/swell-command.js
CHANGED
|
@@ -21,15 +21,6 @@ export class SwellCommand extends Command {
|
|
|
21
21
|
super(argv, config);
|
|
22
22
|
this.api = new Api();
|
|
23
23
|
}
|
|
24
|
-
async catch(error) {
|
|
25
|
-
if (error instanceof GitUnknownError) {
|
|
26
|
-
this.error(style.error(`git: ${error.stderr || error.stdout || error.message}`));
|
|
27
|
-
}
|
|
28
|
-
else if (error instanceof FetchError) {
|
|
29
|
-
this.error(`Could not connect to Swell API. Please try again later: ${error.message}`);
|
|
30
|
-
}
|
|
31
|
-
throw error;
|
|
32
|
-
}
|
|
33
24
|
debugJson(...args) {
|
|
34
25
|
const stringified = args.map((arg) => typeof arg === 'string' ? arg : JSON.stringify(arg, null, 4));
|
|
35
26
|
this.debug(...stringified);
|
|
@@ -40,4 +31,13 @@ export class SwellCommand extends Command {
|
|
|
40
31
|
logSuccess(message) {
|
|
41
32
|
this.log(`${style.success(message)}`);
|
|
42
33
|
}
|
|
34
|
+
async catch(error) {
|
|
35
|
+
if (error instanceof GitUnknownError) {
|
|
36
|
+
this.error(style.error(`git: ${error.stderr || error.stdout || error.message}`));
|
|
37
|
+
}
|
|
38
|
+
else if (error instanceof FetchError) {
|
|
39
|
+
this.error(`Could not connect to Swell API. Please try again later: ${error.message}`);
|
|
40
|
+
}
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
43
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swell/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Swell's command line interface/utility",
|
|
6
6
|
"keywords": [
|
|
@@ -32,6 +32,9 @@
|
|
|
32
32
|
"@oclif/errors": "1.3.6",
|
|
33
33
|
"@oclif/plugin-help": "6.0.4",
|
|
34
34
|
"@oclif/plugin-plugins": "3.9.4",
|
|
35
|
+
"ajv": "8.17.1",
|
|
36
|
+
"ajv-errors": "3.0.0",
|
|
37
|
+
"ajv-formats": "3.0.1",
|
|
35
38
|
"blake3-wasm": "2.1.5",
|
|
36
39
|
"chalk": "5.3.0",
|
|
37
40
|
"conf": "11.0.2",
|
|
@@ -52,6 +55,7 @@
|
|
|
52
55
|
"oclif": "4.0.3",
|
|
53
56
|
"open": "9.1.0",
|
|
54
57
|
"ora": "7.0.1",
|
|
58
|
+
"parse-json": "8.3.0",
|
|
55
59
|
"qs": "6.12.3",
|
|
56
60
|
"semver": "7.5.4",
|
|
57
61
|
"table": "6.8.1",
|
|
@@ -100,6 +104,9 @@
|
|
|
100
104
|
},
|
|
101
105
|
"create": {
|
|
102
106
|
"description": "Create dependencies for your Swell app."
|
|
107
|
+
},
|
|
108
|
+
"inspect": {
|
|
109
|
+
"description": "Inspect deployed artifacts in your store."
|
|
103
110
|
}
|
|
104
111
|
}
|
|
105
112
|
},
|