@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.
- package/dist/app-command.d.ts +1 -1
- package/dist/app-command.js +8 -8
- package/dist/commands/app/dev.d.ts +18 -0
- package/dist/commands/app/dev.js +31 -0
- package/dist/commands/app/frontend/deploy.d.ts +17 -0
- package/dist/commands/app/frontend/deploy.js +44 -0
- package/dist/commands/app/frontend/dev.d.ts +21 -0
- package/dist/commands/app/frontend/dev.js +111 -0
- package/dist/commands/app/info.js +15 -8
- package/dist/commands/app/init.d.ts +12 -0
- package/dist/commands/app/init.js +34 -0
- package/dist/commands/app/install.d.ts +4 -4
- package/dist/commands/app/install.js +37 -42
- package/dist/commands/app/pull.d.ts +15 -0
- package/dist/commands/app/pull.js +50 -0
- package/dist/commands/app/push.d.ts +11 -14
- package/dist/commands/app/push.js +71 -143
- package/dist/commands/app/release.d.ts +13 -0
- package/dist/commands/app/release.js +150 -0
- package/dist/commands/app/version.d.ts +7 -6
- package/dist/commands/app/version.js +64 -43
- package/dist/commands/app/watch.d.ts +2 -4
- package/dist/commands/app/watch.js +3 -83
- package/dist/commands/create/app.d.ts +35 -11
- package/dist/commands/create/app.js +150 -144
- package/dist/commands/create/content.d.ts +2 -2
- package/dist/commands/create/content.js +10 -10
- package/dist/commands/create/frontend.d.ts +12 -0
- package/dist/commands/create/frontend.js +41 -0
- package/dist/commands/create/function.d.ts +3 -3
- package/dist/commands/create/function.js +22 -22
- package/dist/commands/create/model.d.ts +2 -2
- package/dist/commands/create/model.js +11 -11
- package/dist/commands/create/notification.d.ts +4 -4
- package/dist/commands/create/notification.js +38 -40
- package/dist/commands/login.d.ts +1 -1
- package/dist/commands/login.js +12 -9
- package/dist/commands/logs.js +2 -1
- package/dist/commands/theme/dev.d.ts +23 -0
- package/dist/commands/theme/dev.js +167 -0
- package/dist/commands/theme/init.d.ts +9 -0
- package/dist/commands/theme/init.js +15 -0
- package/dist/commands/theme/pull.d.ts +20 -0
- package/dist/commands/theme/pull.js +65 -0
- package/dist/commands/theme/push.d.ts +19 -0
- package/dist/commands/theme/push.js +92 -0
- package/dist/create-app-command.d.ts +20 -0
- package/dist/create-app-command.js +254 -0
- package/dist/create-collection-command.d.ts +9 -9
- package/dist/create-collection-command.js +23 -23
- package/dist/{create-command.d.ts → create-config-command.d.ts} +1 -1
- package/dist/{create-command.js → create-config-command.js} +9 -7
- package/dist/lib/api.d.ts +6 -4
- package/dist/lib/api.js +58 -29
- package/dist/lib/app-config.d.ts +13 -5
- package/dist/lib/app-config.js +60 -23
- package/dist/lib/apps/app-config.d.ts +22 -8
- package/dist/lib/apps/app-config.js +202 -68
- package/dist/lib/apps/index.d.ts +93 -13
- package/dist/lib/apps/index.js +150 -50
- package/dist/lib/apps/paths.d.ts +14 -7
- package/dist/lib/apps/paths.js +73 -28
- package/dist/lib/bundle.js +4 -5
- package/dist/lib/config.d.ts +5 -1
- package/dist/lib/config.js +14 -0
- package/dist/lib/constants.d.ts +5 -0
- package/dist/lib/constants.js +22 -3
- package/dist/lib/create/content.d.ts +2 -2
- package/dist/lib/create/content.js +1 -1
- package/dist/lib/create/function.d.ts +2 -2
- package/dist/lib/create/function.js +2 -2
- package/dist/lib/create/index.d.ts +1 -1
- package/dist/lib/create/index.js +11 -7
- package/dist/lib/create/model.d.ts +2 -2
- package/dist/lib/create/notification.d.ts +2 -2
- package/dist/lib/info.js +2 -2
- package/dist/lib/sessions.js +2 -2
- package/dist/lib/stores.d.ts +5 -2
- package/dist/lib/stores.js +9 -6
- package/dist/lib/style.d.ts +2 -0
- package/dist/lib/style.js +2 -0
- package/dist/lib/swell-function-wrapper.d.ts +2 -2
- package/dist/lib/swell-function-wrapper.js +2 -2
- package/dist/push-app-command.d.ts +73 -0
- package/dist/push-app-command.js +765 -0
- package/dist/remote-app-command.d.ts +35 -9
- package/dist/remote-app-command.js +436 -164
- package/oclif.manifest.json +841 -125
- package/package.json +13 -1
- package/dist/commands/app/_pull.d.ts +0 -8
- package/dist/commands/app/_pull.js +0 -45
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
import isEmpty from 'lodash/isEmpty.js';
|
|
3
3
|
import * as fs from 'node:fs';
|
|
4
4
|
import * as path from 'node:path';
|
|
5
|
+
import { detectFilenameMime } from 'mime-detect';
|
|
6
|
+
import { getEncoding } from 'istextorbinary';
|
|
5
7
|
import { bundleFunction } from '../bundle.js';
|
|
6
|
-
import { ConfigType } from './index.js';
|
|
8
|
+
import { ConfigType, ConfigPaths, hashFile, filePathExists } from './index.js';
|
|
7
9
|
class IgnoringFileError extends Error {
|
|
8
10
|
constructor(message) {
|
|
9
11
|
super(message);
|
|
@@ -23,21 +25,68 @@ class FunctionProcessingError extends Error {
|
|
|
23
25
|
* app & the configuration are saved to the API.
|
|
24
26
|
*/
|
|
25
27
|
class AppConfig {
|
|
26
|
-
|
|
27
|
-
file;
|
|
28
|
-
fileData;
|
|
28
|
+
// Server-side props
|
|
29
29
|
id;
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
version;
|
|
31
|
+
hash;
|
|
32
|
+
fileHash;
|
|
33
|
+
file;
|
|
34
|
+
file_path;
|
|
32
35
|
name;
|
|
33
36
|
parent_id;
|
|
34
37
|
slug;
|
|
35
38
|
values = {};
|
|
39
|
+
date_created;
|
|
40
|
+
date_updated;
|
|
41
|
+
// Used when pushing a theme and the app config is considered
|
|
42
|
+
appConfigId;
|
|
43
|
+
// Relative path of remote AppConfig, same as file_path if defined
|
|
44
|
+
filePath;
|
|
45
|
+
// Full local path of remote AppConfig
|
|
46
|
+
appPath;
|
|
47
|
+
// Buffer of local file data
|
|
48
|
+
fileData;
|
|
49
|
+
// UTF8 content of local file
|
|
50
|
+
fileContent;
|
|
51
|
+
// Size of local file in bytes and mb
|
|
52
|
+
byteSize;
|
|
53
|
+
mbSize;
|
|
36
54
|
constructor(attrs = {}) {
|
|
37
55
|
Object.assign(this, attrs);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
56
|
+
let { filePath, appPath } = attrs;
|
|
57
|
+
this.filePath = filePath || '';
|
|
58
|
+
this.appPath = appPath || '';
|
|
59
|
+
if (!attrs.type || !attrs.name) {
|
|
60
|
+
throw new Error('Missing app config type or name.');
|
|
61
|
+
}
|
|
62
|
+
if (!appPath) {
|
|
63
|
+
throw new Error('Missing app path to initialize config.');
|
|
64
|
+
}
|
|
65
|
+
// Make sure file path is set from server prop or type/name
|
|
66
|
+
if (!filePath) {
|
|
67
|
+
if (attrs.file_path) {
|
|
68
|
+
filePath = attrs.file_path;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
// Note this shouldn't be necessary unless the config was created before file_path was added
|
|
72
|
+
const typePath = ConfigPaths[String(attrs.type).toUpperCase()];
|
|
73
|
+
filePath = `${typePath}/${attrs.name}`;
|
|
74
|
+
if (!typePath) {
|
|
75
|
+
throw new Error(`Missing path for app config type: ${attrs.type}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
this.filePath = filePath;
|
|
79
|
+
}
|
|
80
|
+
if (!appPath.endsWith(filePath)) {
|
|
81
|
+
this.appPath = path.join(appPath, filePath);
|
|
82
|
+
}
|
|
83
|
+
if (filePathExists(this.appPath)) {
|
|
84
|
+
this.fileHash = hashFile(this.appPath);
|
|
85
|
+
this.hash = this.hash || this.fileHash;
|
|
86
|
+
this.fileData = fs.readFileSync(this.appPath);
|
|
87
|
+
this.fileContent = this.fileData.toString('utf8');
|
|
88
|
+
this.byteSize = Buffer.byteLength(this.fileContent);
|
|
89
|
+
this.mbSize = this.byteSize / 1024 / 1024;
|
|
41
90
|
}
|
|
42
91
|
}
|
|
43
92
|
static create(attrs = {}) {
|
|
@@ -51,16 +100,26 @@ class AppConfig {
|
|
|
51
100
|
case ConfigType.MODEL: {
|
|
52
101
|
return new AppConfigModel(attrs);
|
|
53
102
|
}
|
|
103
|
+
case ConfigType.CONTENT: {
|
|
104
|
+
return new AppConfigContent(attrs);
|
|
105
|
+
}
|
|
54
106
|
case ConfigType.NOTIFICATION: {
|
|
55
|
-
// the path can be a tpl file or a json file as we can use the `create`
|
|
56
|
-
// function when watching for changes. We need to make sure that we
|
|
57
|
-
// always use the json file for AppConfig.
|
|
58
|
-
attrs.localPath = AppConfigNotification.actualConfigPath(attrs.localPath);
|
|
59
107
|
return new AppConfigNotification(attrs);
|
|
60
108
|
}
|
|
109
|
+
case ConfigType.SETTING: {
|
|
110
|
+
return new AppConfigSetting(attrs);
|
|
111
|
+
}
|
|
112
|
+
case ConfigType.WEBHOOK: {
|
|
113
|
+
return new AppConfigWebhook(attrs);
|
|
114
|
+
}
|
|
115
|
+
case ConfigType.FRONTEND: {
|
|
116
|
+
return new AppConfigFrontend(attrs);
|
|
117
|
+
}
|
|
118
|
+
case ConfigType.THEME: {
|
|
119
|
+
return new AppConfigTheme(attrs);
|
|
120
|
+
}
|
|
61
121
|
default: {
|
|
62
|
-
// the default type is
|
|
63
|
-
// that we set the expected type
|
|
122
|
+
// the default type is file
|
|
64
123
|
const defaultConfig = new AppConfigDefault(attrs);
|
|
65
124
|
defaultConfig.type = attrs.type;
|
|
66
125
|
return defaultConfig;
|
|
@@ -68,103 +127,178 @@ class AppConfig {
|
|
|
68
127
|
}
|
|
69
128
|
}
|
|
70
129
|
async postData() {
|
|
71
|
-
if (
|
|
72
|
-
throw new Error('Missing local config path');
|
|
73
|
-
}
|
|
74
|
-
if (!this.fileData) {
|
|
130
|
+
if (this.fileContent === undefined) {
|
|
75
131
|
return;
|
|
76
132
|
}
|
|
77
|
-
if (this.
|
|
133
|
+
if (this.hasValues && this.filePath.endsWith('.json')) {
|
|
78
134
|
try {
|
|
79
|
-
this.values = JSON.parse(this.
|
|
135
|
+
this.values = JSON.parse(this.fileContent);
|
|
80
136
|
}
|
|
81
137
|
catch {
|
|
82
|
-
throw new IgnoringFileError('
|
|
138
|
+
throw new IgnoringFileError('Invalid JSON');
|
|
83
139
|
}
|
|
84
140
|
if (isEmpty(this.values)) {
|
|
85
|
-
throw new IgnoringFileError('
|
|
141
|
+
throw new IgnoringFileError('Empty JSON');
|
|
86
142
|
}
|
|
87
143
|
}
|
|
144
|
+
// Detect file content type
|
|
145
|
+
let contentType = detectFilenameMime(this.filePath);
|
|
146
|
+
if (this.filePath.endsWith('.liquid') ||
|
|
147
|
+
this.filePath.endsWith('.liquidx')) {
|
|
148
|
+
contentType = 'application/liquid';
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
contentType = detectFilenameMime(this.filePath);
|
|
152
|
+
}
|
|
88
153
|
const postData = {
|
|
154
|
+
// Name is either configured or the last part of the path without extension
|
|
89
155
|
name: this.values?.name || this.name,
|
|
90
156
|
type: this.type,
|
|
91
|
-
|
|
157
|
+
hash: this.hash,
|
|
158
|
+
file_path: this.filePath,
|
|
159
|
+
file: {
|
|
160
|
+
data: this.prepareFileData(),
|
|
161
|
+
content_type: contentType,
|
|
162
|
+
},
|
|
92
163
|
};
|
|
164
|
+
if (this.hasValues) {
|
|
165
|
+
postData.values = this.values || {};
|
|
166
|
+
}
|
|
93
167
|
return this.preparePostData(postData);
|
|
94
168
|
}
|
|
169
|
+
prepareFileData() {
|
|
170
|
+
if (!this.fileData) {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
return getEncoding(this.fileData) === 'binary'
|
|
174
|
+
? { $base64: this.fileData.toString('base64') }
|
|
175
|
+
: this.fileData?.toString('utf8');
|
|
176
|
+
}
|
|
177
|
+
isRootConfig(configDir) {
|
|
178
|
+
return !this.filePath
|
|
179
|
+
?.replace(new RegExp(`^${configDir}/`), '')
|
|
180
|
+
.includes('/');
|
|
181
|
+
}
|
|
95
182
|
}
|
|
96
183
|
class AppConfigDefault extends AppConfig {
|
|
97
|
-
type = ConfigType.
|
|
184
|
+
type = ConfigType.FILE;
|
|
185
|
+
hasValues = false;
|
|
98
186
|
preparePostData(postData) {
|
|
99
187
|
return postData;
|
|
100
188
|
}
|
|
101
189
|
}
|
|
102
190
|
class AppConfigModel extends AppConfig {
|
|
103
191
|
type = ConfigType.MODEL;
|
|
192
|
+
hasValues = true;
|
|
193
|
+
preparePostData(postData) {
|
|
194
|
+
postData.values.collection =
|
|
195
|
+
postData.values.collection || postData.values.model || this.name;
|
|
196
|
+
return postData;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
class AppConfigContent extends AppConfig {
|
|
200
|
+
type = ConfigType.CONTENT;
|
|
201
|
+
hasValues = true;
|
|
104
202
|
preparePostData(postData) {
|
|
105
|
-
postData.values.collection = this.name;
|
|
203
|
+
postData.values.collection = postData.values.collection || this.name;
|
|
106
204
|
return postData;
|
|
107
205
|
}
|
|
108
206
|
}
|
|
109
207
|
class AppConfigNotification extends AppConfig {
|
|
110
208
|
type = ConfigType.NOTIFICATION;
|
|
111
|
-
|
|
112
|
-
* The actual config path is the path to the JSON file that is used to
|
|
113
|
-
* configure the notification. This function ensures that the path is
|
|
114
|
-
* correct.
|
|
115
|
-
*
|
|
116
|
-
* @param localPath - json or tpl file path
|
|
117
|
-
* @returns - json file path
|
|
118
|
-
*/
|
|
119
|
-
static actualConfigPath(localPath) {
|
|
120
|
-
return localPath?.replace('.tpl', '.json');
|
|
121
|
-
}
|
|
209
|
+
hasValues = true;
|
|
122
210
|
preparePostData(postData) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
211
|
+
const isTemplate = this.isRootConfig('notifications') &&
|
|
212
|
+
(this.filePath.endsWith('.tpl') || this.filePath.endsWith('.liquid'));
|
|
213
|
+
if (isTemplate) {
|
|
214
|
+
// Get json config to match collection/model name
|
|
215
|
+
let jsonData;
|
|
216
|
+
try {
|
|
217
|
+
const jsonPath = this.filePath
|
|
218
|
+
.replace('.tpl', '.json')
|
|
219
|
+
.replace('.liquid', '.json');
|
|
220
|
+
jsonData = JSON.parse(fs.readFileSync(jsonPath, 'utf8'));
|
|
221
|
+
postData.values.collection = jsonData?.collection || jsonData?.model;
|
|
222
|
+
}
|
|
223
|
+
catch (err) {
|
|
224
|
+
// noop
|
|
225
|
+
}
|
|
226
|
+
postData.file = {
|
|
227
|
+
data: this.fileContent?.replaceAll('\r\n', '\n'),
|
|
228
|
+
content_type: 'text/plain',
|
|
133
229
|
};
|
|
134
230
|
}
|
|
135
231
|
return postData;
|
|
136
232
|
}
|
|
137
233
|
}
|
|
234
|
+
class AppConfigSetting extends AppConfig {
|
|
235
|
+
type = ConfigType.SETTING;
|
|
236
|
+
hasValues = true;
|
|
237
|
+
preparePostData(postData) {
|
|
238
|
+
return postData;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
class AppConfigWebhook extends AppConfig {
|
|
242
|
+
type = ConfigType.WEBHOOK;
|
|
243
|
+
hasValues = true;
|
|
244
|
+
preparePostData(postData) {
|
|
245
|
+
return postData;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
138
248
|
class AppConfigFunction extends AppConfig {
|
|
139
249
|
type = ConfigType.FUNCTION;
|
|
250
|
+
hasValues = true;
|
|
140
251
|
async preparePostData(postData) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
252
|
+
const isFunction = this.isRootConfig('functions') &&
|
|
253
|
+
(this.filePath.endsWith('.js') || this.filePath.endsWith('.ts'));
|
|
254
|
+
if (isFunction) {
|
|
255
|
+
try {
|
|
256
|
+
const { code, config } = await bundleFunction(this.filePath);
|
|
257
|
+
if (!config) {
|
|
258
|
+
throw new IgnoringFileError('Function must export a `config` object.');
|
|
259
|
+
}
|
|
260
|
+
// Save the original file and the bundled version
|
|
261
|
+
postData.file = {
|
|
262
|
+
data: this.prepareFileData(),
|
|
263
|
+
};
|
|
264
|
+
postData.build_file = {
|
|
265
|
+
data: code,
|
|
266
|
+
content_type: 'text/javascript',
|
|
267
|
+
};
|
|
268
|
+
postData.values = config;
|
|
269
|
+
}
|
|
270
|
+
catch (error) {
|
|
271
|
+
throw new FunctionProcessingError(`Unable to compile function ${this.name}`, error);
|
|
148
272
|
}
|
|
149
|
-
const fileName = path.basename(this.localPath);
|
|
150
|
-
postData.file = {
|
|
151
|
-
data: code,
|
|
152
|
-
// we keep the file extension so we can easily identify the file path
|
|
153
|
-
// when we need to delete the function
|
|
154
|
-
ext: fileName.replace(this.name, ''),
|
|
155
|
-
};
|
|
156
|
-
postData.values = config;
|
|
157
|
-
}
|
|
158
|
-
catch (error) {
|
|
159
|
-
throw new FunctionProcessingError(`Unable to compile function ${this.name}`, error);
|
|
160
273
|
}
|
|
161
274
|
return postData;
|
|
162
275
|
}
|
|
163
276
|
}
|
|
164
|
-
|
|
277
|
+
// Assets do not get installed but saved as plain files
|
|
278
|
+
class AppConfigAsset extends AppConfigDefault {
|
|
165
279
|
type = ConfigType.ASSET;
|
|
166
|
-
|
|
167
|
-
|
|
280
|
+
hasValues = false;
|
|
281
|
+
}
|
|
282
|
+
class AppConfigFrontend extends AppConfigDefault {
|
|
283
|
+
type = ConfigType.FRONTEND;
|
|
284
|
+
hasValues = false;
|
|
285
|
+
}
|
|
286
|
+
class AppConfigTheme extends AppConfigDefault {
|
|
287
|
+
type = ConfigType.THEME;
|
|
288
|
+
hasValues = false;
|
|
289
|
+
preparePostData(postData) {
|
|
290
|
+
const isConfigJson = this.filePath?.match(/^theme\/config\/[^\.\/]+\.json$/);
|
|
291
|
+
// Files in theme/config/*.json are treated as settings with values
|
|
292
|
+
if (isConfigJson) {
|
|
293
|
+
try {
|
|
294
|
+
const jsonData = JSON.parse(fs.readFileSync(this.filePath, 'utf8'));
|
|
295
|
+
postData.values = jsonData;
|
|
296
|
+
}
|
|
297
|
+
catch (err) {
|
|
298
|
+
// noop
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return postData;
|
|
168
302
|
}
|
|
169
303
|
}
|
|
170
304
|
export { AppConfig, FunctionProcessingError, IgnoringFileError };
|
package/dist/lib/apps/index.d.ts
CHANGED
|
@@ -1,29 +1,89 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { AppConfig } from './app-config.js';
|
|
2
3
|
/**
|
|
3
4
|
* An app as defined by the Swell API. This is different than an app
|
|
4
5
|
* configuration that developers define.
|
|
5
6
|
*/
|
|
6
7
|
type App = {
|
|
8
|
+
id?: string;
|
|
7
9
|
client?: any;
|
|
8
10
|
client_id?: string;
|
|
9
11
|
configs?: AppConfig[];
|
|
10
12
|
date_created?: string;
|
|
11
13
|
date_updated?: string;
|
|
12
14
|
description?: string;
|
|
13
|
-
id?: string;
|
|
14
|
-
installed?: boolean;
|
|
15
15
|
name?: string;
|
|
16
|
+
type?: string;
|
|
17
|
+
kind?: string;
|
|
16
18
|
private_id?: string;
|
|
17
19
|
public_id?: string;
|
|
18
20
|
published?: boolean;
|
|
19
21
|
version?: string;
|
|
22
|
+
compatibilities?: {
|
|
23
|
+
[key: string]: string;
|
|
24
|
+
};
|
|
25
|
+
storefront?: {
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
};
|
|
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
|
+
styles?: Array<{
|
|
44
|
+
id: string;
|
|
45
|
+
label: string;
|
|
46
|
+
color: string;
|
|
47
|
+
color_alt?: string;
|
|
48
|
+
preview_image?: unknown;
|
|
49
|
+
preview_mobile_image?: unknown;
|
|
50
|
+
}>;
|
|
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;
|
|
63
|
+
};
|
|
20
64
|
};
|
|
65
|
+
declare enum SwellJsonFields {
|
|
66
|
+
ID = "id",
|
|
67
|
+
NAME = "name",
|
|
68
|
+
TYPE = "type",
|
|
69
|
+
KIND = "kind",
|
|
70
|
+
VERSION = "version",
|
|
71
|
+
DESCRIPTION = "description",
|
|
72
|
+
STOREFRONT = "storefront",
|
|
73
|
+
THEME = "theme",
|
|
74
|
+
PERMISSIONS = "permissions",
|
|
75
|
+
EXTENSIONS = "extensions"
|
|
76
|
+
}
|
|
21
77
|
type AppVersion = {
|
|
22
78
|
date_created: string;
|
|
23
79
|
id: string;
|
|
24
80
|
name: string;
|
|
25
|
-
notes: string;
|
|
26
81
|
version: string;
|
|
82
|
+
description?: string;
|
|
83
|
+
released?: boolean;
|
|
84
|
+
release_notes?: string;
|
|
85
|
+
published?: boolean;
|
|
86
|
+
supported?: boolean;
|
|
27
87
|
};
|
|
28
88
|
declare enum ConfigType {
|
|
29
89
|
ASSET = "asset",
|
|
@@ -32,12 +92,19 @@ declare enum ConfigType {
|
|
|
32
92
|
MODEL = "model",
|
|
33
93
|
NOTIFICATION = "notification",
|
|
34
94
|
SETTING = "setting",
|
|
35
|
-
WEBHOOK = "webhook"
|
|
95
|
+
WEBHOOK = "webhook",
|
|
96
|
+
FRONTEND = "frontend",
|
|
97
|
+
THEME = "theme",
|
|
98
|
+
FILE = "file"
|
|
36
99
|
}
|
|
100
|
+
declare const StorefrontConfigTypes: string[];
|
|
101
|
+
declare const ThemeConfigTypes: string[];
|
|
37
102
|
type ConfigPathsType = {
|
|
38
103
|
[key in ConfigType]: string;
|
|
39
104
|
};
|
|
40
105
|
declare const ConfigPaths: ConfigPathsType;
|
|
106
|
+
declare const StorefrontConfigPaths: ConfigPathsType;
|
|
107
|
+
declare const ThemeConfigPaths: ConfigPathsType;
|
|
41
108
|
declare enum ConfigInputFields {
|
|
42
109
|
FILE = "file",
|
|
43
110
|
NAME = "name",
|
|
@@ -45,23 +112,36 @@ declare enum ConfigInputFields {
|
|
|
45
112
|
VALUES = "values",
|
|
46
113
|
VERSION = "version"
|
|
47
114
|
}
|
|
48
|
-
|
|
115
|
+
type FrontendProjectType = {
|
|
116
|
+
name: string;
|
|
117
|
+
slug: string;
|
|
118
|
+
configFileName: string;
|
|
119
|
+
deployPath: string;
|
|
120
|
+
installCommand: string;
|
|
121
|
+
buildCommand: string;
|
|
122
|
+
devCommand: string;
|
|
123
|
+
};
|
|
124
|
+
declare const FrontendProjectTypes: Array<FrontendProjectType>;
|
|
125
|
+
declare function getAppSlugId(app: App): string | undefined;
|
|
126
|
+
declare function getFrontendProjectType(appPath: string): FrontendProjectType | undefined;
|
|
49
127
|
declare function getConfigTypeFromPath(path: string): ConfigType | undefined;
|
|
50
128
|
declare function getConfigTypeKeyFromValue(value: string): string | undefined;
|
|
51
|
-
declare function
|
|
129
|
+
declare function filePathExists(filePath: string): boolean;
|
|
52
130
|
declare function writeFile(file: string, data: string): Promise<void>;
|
|
131
|
+
declare function deleteFile(file: string): Promise<void>;
|
|
53
132
|
declare function writeJsonFile(file: string, data?: any): Promise<void>;
|
|
54
|
-
declare function
|
|
55
|
-
declare function
|
|
56
|
-
declare function
|
|
57
|
-
declare function
|
|
133
|
+
declare function hashFile(filePath: string, fileContents?: Buffer): string;
|
|
134
|
+
declare function hashString(contents: string): string;
|
|
135
|
+
declare function appAssetImage(appPath: string, fileName: string): string | undefined;
|
|
136
|
+
declare function appConfigFromFile(filePath: string, configType: ConfigType, appPath: string): AppConfig;
|
|
137
|
+
declare function findAppConfig(app: App, filePath: string, configType: ConfigType): AppConfig | undefined;
|
|
58
138
|
/**
|
|
59
139
|
* Get files to push in batches prioritized by dependencies
|
|
60
140
|
*
|
|
61
141
|
* @param appConfigs - List of app configs
|
|
62
142
|
* @returns {Array} Batches of files to push
|
|
63
143
|
*/
|
|
64
|
-
declare function
|
|
65
|
-
export { App, AppVersion, ConfigInputFields, ConfigPaths, ConfigPathsType, ConfigType, appConfigFromFile,
|
|
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, };
|
|
66
146
|
export { AppConfig, FunctionProcessingError, IgnoringFileError, } from './app-config.js';
|
|
67
|
-
export { allConfigDirsPaths, allConfigFilesPaths, allConfigFilesPathsByType,
|
|
147
|
+
export { globAllFilesByPath, allConfigDirsPaths, allConfigFilesPaths, allConfigFilesPathsByType, allConfigFilesInDir, allBaseFilesInDir, isPathDirectory, getAllConfigPaths, } from './paths.js';
|