@swell/cli 2.0.11 → 2.0.12
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/app/dev.d.ts +1 -1
- package/dist/commands/app/dev.js +1 -1
- package/dist/commands/app/install.js +1 -1
- package/dist/commands/app/pull.d.ts +4 -1
- package/dist/commands/app/pull.js +9 -6
- package/dist/commands/app/push.d.ts +4 -2
- package/dist/commands/app/push.js +1 -1
- package/dist/commands/app/release.d.ts +3 -0
- package/dist/commands/app/release.js +3 -0
- package/dist/commands/app/version.d.ts +3 -0
- package/dist/commands/app/version.js +3 -0
- package/dist/commands/login.js +1 -1
- package/dist/commands/theme/dev.d.ts +1 -3
- package/dist/commands/theme/dev.js +12 -6
- package/dist/commands/theme/pull.d.ts +1 -2
- package/dist/commands/theme/pull.js +4 -2
- package/dist/commands/theme/push.d.ts +1 -2
- package/dist/commands/theme/push.js +17 -4
- package/dist/lib/api.d.ts +5 -4
- package/dist/lib/api.js +16 -3
- package/dist/lib/apps/app-config.d.ts +6 -6
- package/dist/lib/apps/app-config.js +4 -5
- package/dist/lib/apps/index.d.ts +36 -35
- package/dist/lib/apps/index.js +60 -62
- package/dist/lib/apps/paths.d.ts +10 -9
- package/dist/lib/apps/paths.js +36 -32
- package/dist/lib/config.d.ts +5 -2
- package/dist/lib/config.js +11 -3
- package/dist/lib/stores.js +2 -2
- package/dist/push-app-command.d.ts +24 -9
- package/dist/push-app-command.js +112 -61
- package/dist/remote-app-command.d.ts +1 -1
- package/dist/remote-app-command.js +7 -7
- package/oclif.manifest.json +41 -8
- package/package.json +2 -2
package/dist/lib/apps/index.js
CHANGED
|
@@ -4,8 +4,10 @@ import * as fs from 'node:fs';
|
|
|
4
4
|
import * as path from 'node:path';
|
|
5
5
|
import { toAppId } from '../create/index.js';
|
|
6
6
|
import { AppConfig } from './app-config.js';
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
export { AppConfig, FunctionProcessingError, IgnoringFileError, } from './app-config.js';
|
|
8
|
+
export { allBaseFilesInDir, allConfigDirsPaths, allConfigFilesInDir, allConfigFilesPaths, allConfigFilesPathsByType, getAllConfigPaths, globAllFilesByPath, isPathDirectory, } from './paths.js';
|
|
9
|
+
export const PUSH_CONCURRENCY = 3;
|
|
10
|
+
export var SwellJsonFields;
|
|
9
11
|
(function (SwellJsonFields) {
|
|
10
12
|
SwellJsonFields["DESCRIPTION"] = "description";
|
|
11
13
|
SwellJsonFields["EXTENSIONS"] = "extensions";
|
|
@@ -18,7 +20,7 @@ var SwellJsonFields;
|
|
|
18
20
|
SwellJsonFields["TYPE"] = "type";
|
|
19
21
|
SwellJsonFields["VERSION"] = "version";
|
|
20
22
|
})(SwellJsonFields || (SwellJsonFields = {}));
|
|
21
|
-
var ConfigType;
|
|
23
|
+
export var ConfigType;
|
|
22
24
|
(function (ConfigType) {
|
|
23
25
|
ConfigType["ASSET"] = "asset";
|
|
24
26
|
ConfigType["CONTENT"] = "content";
|
|
@@ -56,30 +58,35 @@ const StandardConfigTypes = [
|
|
|
56
58
|
'WEBHOOK',
|
|
57
59
|
'THEME',
|
|
58
60
|
];
|
|
59
|
-
const StorefrontConfigTypes = [
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
export const StorefrontConfigTypes = [
|
|
62
|
+
'FRONTEND',
|
|
63
|
+
'ASSET',
|
|
64
|
+
'SETTING',
|
|
65
|
+
];
|
|
66
|
+
export const ThemeConfigTypes = ['THEME', 'ASSET'];
|
|
67
|
+
const getConfigPaths = (types) =>
|
|
68
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
69
|
+
Object.keys(ConfigType).reduce((acc, type) => {
|
|
70
|
+
if (types.includes(type)) {
|
|
66
71
|
// a bit of a hack to make the path singular for content configs
|
|
67
72
|
// need to refactor this to a function if we add more exceptions
|
|
68
|
-
type
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
73
|
+
acc[type] =
|
|
74
|
+
type === 'CONTENT' || type === 'FRONTEND' || type === 'THEME'
|
|
75
|
+
? type.toLowerCase()
|
|
76
|
+
: pluralize(type.toLowerCase());
|
|
77
|
+
}
|
|
78
|
+
return acc;
|
|
79
|
+
}, {});
|
|
80
|
+
export const ConfigPaths = {
|
|
74
81
|
...getConfigPaths(StandardConfigTypes),
|
|
75
82
|
};
|
|
76
|
-
const StorefrontConfigPaths = {
|
|
83
|
+
export const StorefrontConfigPaths = {
|
|
77
84
|
...getConfigPaths(StorefrontConfigTypes),
|
|
78
85
|
};
|
|
79
|
-
const ThemeConfigPaths = {
|
|
86
|
+
export const ThemeConfigPaths = {
|
|
80
87
|
...getConfigPaths(ThemeConfigTypes),
|
|
81
88
|
};
|
|
82
|
-
var ConfigInputFields;
|
|
89
|
+
export var ConfigInputFields;
|
|
83
90
|
(function (ConfigInputFields) {
|
|
84
91
|
ConfigInputFields["FILE"] = "file";
|
|
85
92
|
ConfigInputFields["NAME"] = "name";
|
|
@@ -87,7 +94,7 @@ var ConfigInputFields;
|
|
|
87
94
|
ConfigInputFields["VALUES"] = "values";
|
|
88
95
|
ConfigInputFields["VERSION"] = "version";
|
|
89
96
|
})(ConfigInputFields || (ConfigInputFields = {}));
|
|
90
|
-
const FrontendProjectTypes = [
|
|
97
|
+
export const FrontendProjectTypes = [
|
|
91
98
|
{
|
|
92
99
|
buildCommand: 'npx @cloudflare/next-on-pages',
|
|
93
100
|
configFileName: 'next.config',
|
|
@@ -108,10 +115,10 @@ const FrontendProjectTypes = [
|
|
|
108
115
|
},
|
|
109
116
|
];
|
|
110
117
|
const frontendProjectConfigExtensions = ['.mjs', '.js'];
|
|
111
|
-
function getAppSlugId(app) {
|
|
118
|
+
export function getAppSlugId(app) {
|
|
112
119
|
return toAppId(app.private_id) || app.public_id || app.id;
|
|
113
120
|
}
|
|
114
|
-
function getFrontendProjectType(appPath) {
|
|
121
|
+
export function getFrontendProjectType(appPath) {
|
|
115
122
|
for (const projectType of FrontendProjectTypes) {
|
|
116
123
|
for (const extension of frontendProjectConfigExtensions) {
|
|
117
124
|
const configFile = path.join(appPath, 'frontend', `${projectType.configFileName}${extension}`);
|
|
@@ -121,7 +128,7 @@ function getFrontendProjectType(appPath) {
|
|
|
121
128
|
}
|
|
122
129
|
}
|
|
123
130
|
}
|
|
124
|
-
function getConfigTypeFromPath(path) {
|
|
131
|
+
export function getConfigTypeFromPath(path) {
|
|
125
132
|
for (const type in ConfigPaths) {
|
|
126
133
|
if (ConfigPaths[type] === path) {
|
|
127
134
|
const configType = ConfigType[type];
|
|
@@ -130,10 +137,10 @@ function getConfigTypeFromPath(path) {
|
|
|
130
137
|
}
|
|
131
138
|
return undefined;
|
|
132
139
|
}
|
|
133
|
-
function getConfigTypeKeyFromValue(value) {
|
|
140
|
+
export function getConfigTypeKeyFromValue(value) {
|
|
134
141
|
return Object.keys(ConfigType).find((key) => ConfigType[key] === value);
|
|
135
142
|
}
|
|
136
|
-
function filePathExists(filePath) {
|
|
143
|
+
export function filePathExists(filePath) {
|
|
137
144
|
try {
|
|
138
145
|
// eslint-disable-next-line no-bitwise
|
|
139
146
|
fs.accessSync(filePath, fs.constants.R_OK | fs.constants.W_OK);
|
|
@@ -146,58 +153,54 @@ function filePathExists(filePath) {
|
|
|
146
153
|
return false;
|
|
147
154
|
}
|
|
148
155
|
}
|
|
149
|
-
async function
|
|
156
|
+
export async function filePathExistsAsync(filePath) {
|
|
157
|
+
try {
|
|
158
|
+
// eslint-disable-next-line no-bitwise
|
|
159
|
+
await fs.promises.access(filePath, fs.constants.R_OK | fs.constants.W_OK);
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
if (error.code !== 'ENOENT') {
|
|
164
|
+
throw error;
|
|
165
|
+
}
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
export async function writeFile(file, data) {
|
|
150
170
|
// Convert from base64 if needed
|
|
151
171
|
let contents;
|
|
152
172
|
try {
|
|
153
|
-
const
|
|
154
|
-
|
|
173
|
+
const decoded = Buffer.from(data, 'base64');
|
|
174
|
+
const isBase64 = decoded.toString('base64') === data;
|
|
175
|
+
contents = isBase64 ? decoded : data;
|
|
155
176
|
}
|
|
156
177
|
catch {
|
|
157
178
|
contents = data;
|
|
158
179
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
if (error) {
|
|
162
|
-
throw error;
|
|
163
|
-
}
|
|
164
|
-
fs.writeFile(file, contents || '', (error) => {
|
|
165
|
-
if (error) {
|
|
166
|
-
throw error;
|
|
167
|
-
}
|
|
168
|
-
resolve();
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
});
|
|
180
|
+
await fs.promises.mkdir(path.dirname(file), { recursive: true });
|
|
181
|
+
await fs.promises.writeFile(file, contents);
|
|
172
182
|
}
|
|
173
|
-
function deleteFile(file) {
|
|
174
|
-
return
|
|
175
|
-
fs.unlink(file, (error) => {
|
|
176
|
-
if (error) {
|
|
177
|
-
throw error;
|
|
178
|
-
}
|
|
179
|
-
resolve();
|
|
180
|
-
});
|
|
181
|
-
});
|
|
183
|
+
export function deleteFile(file) {
|
|
184
|
+
return fs.promises.unlink(file);
|
|
182
185
|
}
|
|
183
|
-
async function writeJsonFile(file, data = {}) {
|
|
186
|
+
export async function writeJsonFile(file, data = {}) {
|
|
184
187
|
return writeFile(file, `${JSON.stringify(data, null, 2)}\n`);
|
|
185
188
|
}
|
|
186
189
|
// Hash method adapted from wrangler-sdk
|
|
187
|
-
function hashFile(filePath, fileContents, relativePath) {
|
|
190
|
+
export function hashFile(filePath, fileContents, relativePath) {
|
|
188
191
|
const contents = fileContents ?? fs.readFileSync(filePath);
|
|
189
192
|
// Include relative file path because we typically cache by hash including file metadata
|
|
190
193
|
// This allows de-duplication of cache entries for the same file contents
|
|
191
194
|
return hashString(contents, relativePath || '');
|
|
192
195
|
}
|
|
193
|
-
function hashString(...contents) {
|
|
196
|
+
export function hashString(...contents) {
|
|
194
197
|
const hash = createBlake3Hash();
|
|
195
198
|
for (const content of contents) {
|
|
196
199
|
hash.update(content);
|
|
197
200
|
}
|
|
198
201
|
return hash.digest('hex', { length: 16 });
|
|
199
202
|
}
|
|
200
|
-
function appAssetImage(appPath, fileName) {
|
|
203
|
+
export function appAssetImage(appPath, fileName) {
|
|
201
204
|
const assetsDirPath = path.join(appPath, ConfigPaths['ASSET']);
|
|
202
205
|
if (!filePathExists(assetsDirPath)) {
|
|
203
206
|
return;
|
|
@@ -208,7 +211,7 @@ function appAssetImage(appPath, fileName) {
|
|
|
208
211
|
}
|
|
209
212
|
}
|
|
210
213
|
}
|
|
211
|
-
function appConfigFromFile(filePath, configType, appPath) {
|
|
214
|
+
export function appConfigFromFile(filePath, configType, appPath) {
|
|
212
215
|
const { name } = path.parse(filePath);
|
|
213
216
|
const config = AppConfig.create({
|
|
214
217
|
name,
|
|
@@ -223,7 +226,7 @@ function appConfigFromFile(filePath, configType, appPath) {
|
|
|
223
226
|
}
|
|
224
227
|
return config;
|
|
225
228
|
}
|
|
226
|
-
function findAppConfig(app, filePath, configType) {
|
|
229
|
+
export function findAppConfig(app, filePath, configType) {
|
|
227
230
|
const { name } = path.parse(filePath);
|
|
228
231
|
const config = app?.configs?.find((c) => c && c.type === configType && c.name === name);
|
|
229
232
|
return config;
|
|
@@ -234,7 +237,7 @@ function findAppConfig(app, filePath, configType) {
|
|
|
234
237
|
* @param {AppConfig[]} configs - List of app configs
|
|
235
238
|
* @returns {BatchAppFiles[]} Batches of files to push
|
|
236
239
|
*/
|
|
237
|
-
function batchAppFilesByType(configs) {
|
|
240
|
+
export function batchAppFilesByType(configs) {
|
|
238
241
|
const modelsWithExtends = configs.filter((config) => config.type === 'model' && config.values.extends);
|
|
239
242
|
const modelsWithoutExtends = configs.filter((config) => config.type === 'model' && !config.values.extends);
|
|
240
243
|
const contentTypesWithCollection = configs.filter((config) => config.type === 'content' && config.values.collection);
|
|
@@ -266,8 +269,3 @@ function batchAppFilesByType(configs) {
|
|
|
266
269
|
// Add base files if config types are not specified
|
|
267
270
|
return batches;
|
|
268
271
|
}
|
|
269
|
-
export { PUSH_CONCURRENCY, ConfigInputFields, ConfigPaths, ConfigType, FrontendProjectTypes, StorefrontConfigPaths, StorefrontConfigTypes, SwellJsonFields, ThemeConfigPaths, ThemeConfigTypes, appAssetImage, appConfigFromFile, batchAppFilesByType, deleteFile, filePathExists, findAppConfig,
|
|
270
|
-
// functions
|
|
271
|
-
getAppSlugId, getConfigTypeFromPath, getConfigTypeKeyFromValue, getFrontendProjectType, hashFile, hashString, writeFile, writeJsonFile, };
|
|
272
|
-
export { AppConfig, FunctionProcessingError, IgnoringFileError, } from './app-config.js';
|
|
273
|
-
export { allBaseFilesInDir, allConfigDirsPaths, allConfigFilesInDir, allConfigFilesPaths, allConfigFilesPathsByType, getAllConfigPaths, globAllFilesByPath, isPathDirectory, } from './paths.js';
|
package/dist/lib/apps/paths.d.ts
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
|
+
import { type GlobbyFilterFunction } from 'globby';
|
|
1
2
|
import { ConfigType } from './index.js';
|
|
2
|
-
declare function globAllFilesByPath(appPath: string, dirPath?: string): string[]
|
|
3
|
-
declare function
|
|
3
|
+
export declare function globAllFilesByPath(appPath: string, dirPath?: string): Promise<string[]>;
|
|
4
|
+
export declare function getGlobIgnorePathsChecker(appPath: string): Promise<GlobbyFilterFunction>;
|
|
5
|
+
export declare function allConfigDirsPaths(appPath: string): Generator<{
|
|
4
6
|
configDir: string;
|
|
5
7
|
configType: ConfigType;
|
|
6
8
|
}>;
|
|
7
|
-
declare function allConfigFilesPaths(appPath: string): Generator<{
|
|
9
|
+
export declare function allConfigFilesPaths(appPath: string): Generator<{
|
|
8
10
|
configDir: string;
|
|
9
11
|
configFile: string;
|
|
10
12
|
configType: ConfigType;
|
|
11
13
|
}, void, unknown>;
|
|
12
|
-
declare function allConfigFilesPathsByType(appPath: string, configTypeKey: string): Generator<{
|
|
14
|
+
export declare function allConfigFilesPathsByType(appPath: string, configTypeKey: string): Generator<{
|
|
13
15
|
configDir: string;
|
|
14
16
|
configFile: string;
|
|
15
17
|
configType: ConfigType;
|
|
16
18
|
}, void, unknown>;
|
|
17
|
-
declare function allConfigFilesInDir(appPath: string, dirPath: string, configType: ConfigType): Generator<{
|
|
19
|
+
export declare function allConfigFilesInDir(appPath: string, dirPath: string, configType: ConfigType): Generator<{
|
|
18
20
|
configDir: string;
|
|
19
21
|
configFile: string;
|
|
20
22
|
configType: ConfigType;
|
|
21
23
|
}, void, unknown>;
|
|
22
|
-
declare function allBaseFilesInDir(appPath: string): Generator<string, void, unknown>;
|
|
23
|
-
declare function getAllConfigPaths(appType: string):
|
|
24
|
-
declare function isPathDirectory(path: string): boolean;
|
|
25
|
-
export { allBaseFilesInDir, allConfigDirsPaths, allConfigFilesInDir, allConfigFilesPaths, allConfigFilesPathsByType, getAllConfigPaths, globAllFilesByPath, isPathDirectory, };
|
|
24
|
+
export declare function allBaseFilesInDir(appPath: string): Generator<string, void, unknown>;
|
|
25
|
+
export declare function getAllConfigPaths(appType: string): string[];
|
|
26
|
+
export declare function isPathDirectory(path: string): boolean;
|
package/dist/lib/apps/paths.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { globbySync } from 'globby';
|
|
1
|
+
import { globby, globbySync, isGitIgnored, } from 'globby';
|
|
2
2
|
import * as fs from 'node:fs';
|
|
3
3
|
import * as path from 'node:path';
|
|
4
4
|
import { ConfigPaths, ConfigType, StorefrontConfigPaths, ThemeConfigPaths, filePathExists, } from './index.js';
|
|
5
|
-
function
|
|
6
|
-
|
|
5
|
+
function globOptions(appPath, options) {
|
|
6
|
+
return {
|
|
7
7
|
cwd: appPath,
|
|
8
8
|
dot: true,
|
|
9
9
|
gitignore: true,
|
|
@@ -18,75 +18,80 @@ function globFiles(pattern, appPath, dirPath = '.', options = {}) {
|
|
|
18
18
|
'**/yarn.lock',
|
|
19
19
|
...(options?.ignore || []),
|
|
20
20
|
],
|
|
21
|
-
}
|
|
22
|
-
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function globFilesSync(pattern, appPath, dirPath = '.', options = {}) {
|
|
24
|
+
return globbySync(`${dirPath}${path.sep}${pattern}`, globOptions(appPath, options));
|
|
25
|
+
}
|
|
26
|
+
function globFiles(pattern, appPath, dirPath = '.', options = {}) {
|
|
27
|
+
return globby(`${dirPath}${path.sep}${pattern}`, globOptions(appPath, options));
|
|
23
28
|
}
|
|
24
|
-
function globAllFilesByPath(appPath, dirPath) {
|
|
29
|
+
export function globAllFilesByPath(appPath, dirPath) {
|
|
25
30
|
return globFiles('**', appPath, dirPath);
|
|
26
31
|
}
|
|
27
|
-
function
|
|
32
|
+
export function getGlobIgnorePathsChecker(appPath) {
|
|
33
|
+
return isGitIgnored({ cwd: appPath });
|
|
34
|
+
}
|
|
35
|
+
function getConfigDirsPaths(appPath) {
|
|
28
36
|
const configDirsPaths = [];
|
|
29
|
-
for (const type
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (filePathExists(configDir)) {
|
|
38
|
-
configDirsPaths.push({ configDir: configPath, configType });
|
|
39
|
-
}
|
|
37
|
+
for (const [type, configType] of Object.entries(ConfigType)) {
|
|
38
|
+
const configPath = ConfigPaths[type];
|
|
39
|
+
if (!configPath) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
const configDir = path.join(appPath, configPath);
|
|
43
|
+
if (filePathExists(configDir)) {
|
|
44
|
+
configDirsPaths.push({ configDir: configPath, configType });
|
|
40
45
|
}
|
|
41
46
|
}
|
|
42
47
|
return configDirsPaths;
|
|
43
48
|
}
|
|
44
|
-
function* allConfigDirsPaths(appPath) {
|
|
45
|
-
for (const { configDir, configType } of
|
|
49
|
+
export function* allConfigDirsPaths(appPath) {
|
|
50
|
+
for (const { configDir, configType } of getConfigDirsPaths(appPath)) {
|
|
46
51
|
yield { configDir, configType };
|
|
47
52
|
}
|
|
48
53
|
}
|
|
49
|
-
function* allConfigFilesPaths(appPath) {
|
|
54
|
+
export function* allConfigFilesPaths(appPath) {
|
|
50
55
|
for (const { configDir, configType } of allConfigDirsPaths(appPath)) {
|
|
51
56
|
yield* allConfigFilesInDir(appPath, configDir, configType);
|
|
52
57
|
}
|
|
53
58
|
}
|
|
54
|
-
function* allConfigFilesPathsByType(appPath, configTypeKey) {
|
|
59
|
+
export function* allConfigFilesPathsByType(appPath, configTypeKey) {
|
|
55
60
|
const configPath = ConfigPaths[configTypeKey];
|
|
56
61
|
yield* allConfigFilesInDir(appPath, configPath, ConfigType[configTypeKey]);
|
|
57
62
|
}
|
|
58
|
-
function* allConfigFilesInDir(appPath, dirPath, configType) {
|
|
59
|
-
const filePaths =
|
|
63
|
+
export function* allConfigFilesInDir(appPath, dirPath, configType) {
|
|
64
|
+
const filePaths = globFilesSync('**', appPath, dirPath);
|
|
60
65
|
for (const configFile of filePaths) {
|
|
61
66
|
yield { configDir: dirPath, configFile, configType };
|
|
62
67
|
}
|
|
63
68
|
}
|
|
64
|
-
function* allBaseFilesInDir(appPath) {
|
|
69
|
+
export function* allBaseFilesInDir(appPath) {
|
|
65
70
|
// Only get base files excluding config directories
|
|
66
|
-
const configPaths =
|
|
67
|
-
const baseFiles =
|
|
71
|
+
const configPaths = getConfigDirsPaths(appPath);
|
|
72
|
+
const baseFiles = globFilesSync('**', appPath, '.', {
|
|
68
73
|
ignore: configPaths.map((config) => `${config.configDir}/**`),
|
|
69
74
|
});
|
|
70
75
|
for (const path of baseFiles) {
|
|
71
76
|
yield path;
|
|
72
77
|
}
|
|
73
78
|
}
|
|
74
|
-
function getAllConfigPaths(appType) {
|
|
79
|
+
export function getAllConfigPaths(appType) {
|
|
75
80
|
const configPaths = [];
|
|
76
81
|
const ConfigPathsByType = appType === 'storefront'
|
|
77
82
|
? StorefrontConfigPaths
|
|
78
83
|
: appType === 'theme'
|
|
79
84
|
? ThemeConfigPaths
|
|
80
85
|
: ConfigPaths;
|
|
81
|
-
for (const type
|
|
82
|
-
if (Object.
|
|
86
|
+
for (const type of Object.keys(ConfigPathsByType)) {
|
|
87
|
+
if (Object.hasOwn(ConfigPaths, type)) {
|
|
83
88
|
const configPath = ConfigPaths[type];
|
|
84
89
|
configPaths.push(configPath);
|
|
85
90
|
}
|
|
86
91
|
}
|
|
87
92
|
return configPaths;
|
|
88
93
|
}
|
|
89
|
-
function isPathDirectory(path) {
|
|
94
|
+
export function isPathDirectory(path) {
|
|
90
95
|
try {
|
|
91
96
|
const stat = fs.statSync(path);
|
|
92
97
|
return stat.isDirectory();
|
|
@@ -96,4 +101,3 @@ function isPathDirectory(path) {
|
|
|
96
101
|
return false;
|
|
97
102
|
}
|
|
98
103
|
}
|
|
99
|
-
export { allBaseFilesInDir, allConfigDirsPaths, allConfigFilesInDir, allConfigFilesPaths, allConfigFilesPathsByType, getAllConfigPaths, globAllFilesByPath, isPathDirectory, };
|
package/dist/lib/config.d.ts
CHANGED
|
@@ -7,8 +7,11 @@ declare function get(key: string): any;
|
|
|
7
7
|
declare function getAll(): any;
|
|
8
8
|
declare function getDefaultStore(): string;
|
|
9
9
|
declare function setDefaultStore(storeId: string): void;
|
|
10
|
-
declare function getDefaultStorefront(appPath: string):
|
|
11
|
-
|
|
10
|
+
declare function getDefaultStorefront(appPath: string): {
|
|
11
|
+
id: string;
|
|
12
|
+
env?: string;
|
|
13
|
+
};
|
|
14
|
+
declare function setDefaultStorefront(appPath: string, storefrontId: string, env?: string): void;
|
|
12
15
|
declare function getSessionId(storeId: string): any;
|
|
13
16
|
/**
|
|
14
17
|
* Set store data for later access.
|
package/dist/lib/config.js
CHANGED
|
@@ -105,13 +105,21 @@ function setDefaultStore(storeId) {
|
|
|
105
105
|
function getDefaultStorefront(appPath) {
|
|
106
106
|
const storeId = getDefaultStore();
|
|
107
107
|
const defaultStorefronts = configStore.get('defaultStorefronts') || {};
|
|
108
|
-
|
|
108
|
+
const value = defaultStorefronts[storeId]?.[appPath];
|
|
109
|
+
// Backward compatibility with env, which was only used in test env before 3/2025
|
|
110
|
+
if (typeof value === 'string') {
|
|
111
|
+
return { id: value, env: 'test' };
|
|
112
|
+
}
|
|
113
|
+
return value;
|
|
109
114
|
}
|
|
110
|
-
function setDefaultStorefront(appPath, storefrontId) {
|
|
115
|
+
function setDefaultStorefront(appPath, storefrontId, env) {
|
|
111
116
|
const storeId = getDefaultStore();
|
|
112
117
|
const defaultStorefronts = configStore.get('defaultStorefronts') || {};
|
|
113
118
|
defaultStorefronts[storeId] = defaultStorefronts[storeId] || {};
|
|
114
|
-
defaultStorefronts[storeId][appPath] =
|
|
119
|
+
defaultStorefronts[storeId][appPath] = {
|
|
120
|
+
id: storefrontId,
|
|
121
|
+
env,
|
|
122
|
+
};
|
|
115
123
|
return configStore.set('defaultStorefronts', defaultStorefronts);
|
|
116
124
|
}
|
|
117
125
|
function getSessionId(storeId) {
|
package/dist/lib/stores.js
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
import type { GlobbyFilterFunction } from 'globby';
|
|
3
|
+
import * as fs from 'node:fs';
|
|
2
4
|
import { App, AppConfig, ConfigType, FrontendProjectType } from './lib/apps/index.js';
|
|
3
5
|
import { RemoteAppCommand } from './remote-app-command.js';
|
|
4
6
|
type WatchFileEvent = 'change' | 'deleted' | 'new';
|
|
7
|
+
interface WatchingChange {
|
|
8
|
+
action: 'push' | 'remove';
|
|
9
|
+
appConfig: AppConfig;
|
|
10
|
+
configFile: string;
|
|
11
|
+
}
|
|
5
12
|
export declare abstract class PushAppCommand extends RemoteAppCommand {
|
|
6
13
|
frontendPath: string;
|
|
7
14
|
logWatchChanges: boolean;
|
|
8
|
-
onWatchChange?: (
|
|
9
|
-
watchingChangeQueue:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
onWatchChange?: (appConfig?: AppConfig, result?: any) => void;
|
|
16
|
+
watchingChangeQueue: Map<string, WatchingChange>;
|
|
17
|
+
watchingFiles: Set<string>;
|
|
18
|
+
watchingIgnoreFilter: GlobbyFilterFunction | null;
|
|
19
|
+
watchingTimer: NodeJS.Timeout | null;
|
|
20
|
+
watchListener: (eventType: fs.WatchEventType, filename: null | string) => Promise<void>;
|
|
13
21
|
buildFrontend(projectType: FrontendProjectType): Promise<void>;
|
|
14
22
|
chooseAppToPull(query?: any): Promise<App>;
|
|
15
23
|
createAppStorefront(hasOtherStorefronts?: boolean): Promise<any>;
|
|
@@ -43,11 +51,18 @@ export declare abstract class PushAppCommand extends RemoteAppCommand {
|
|
|
43
51
|
}, flags?: {
|
|
44
52
|
'storefront-id'?: string;
|
|
45
53
|
'storefront-select'?: boolean;
|
|
54
|
+
env?: string;
|
|
46
55
|
}): Promise<any>;
|
|
47
56
|
getStorefrontToPush(flags?: {
|
|
48
57
|
'storefront-id'?: string;
|
|
49
58
|
'storefront-select'?: boolean;
|
|
59
|
+
env?: string;
|
|
50
60
|
}): Promise<any>;
|
|
61
|
+
setStorefrontEnv(flags: {
|
|
62
|
+
'storefront-id'?: string;
|
|
63
|
+
'storefront-select'?: boolean;
|
|
64
|
+
env?: string;
|
|
65
|
+
}, defaultStorefront?: any): Promise<void>;
|
|
51
66
|
handleWatchFileChange(configFile: string, configType: ConfigType, event: WatchFileEvent): Promise<void>;
|
|
52
67
|
logAppFrontendUrl(): void;
|
|
53
68
|
logDashboardUrl(flags: {
|
|
@@ -60,12 +75,12 @@ export declare abstract class PushAppCommand extends RemoteAppCommand {
|
|
|
60
75
|
resolveAppPath(appId?: string, targetPath?: string): string;
|
|
61
76
|
runWatchChangeQueue(): Promise<void>;
|
|
62
77
|
saveCurrentStorefront(): void;
|
|
63
|
-
setWatchingFiles(): void
|
|
78
|
+
setWatchingFiles(): Promise<void>;
|
|
64
79
|
updateFrontendDeployment(currentStore: string, projectType: FrontendProjectType, deploymentUrl: string, deploymentHash: string): Promise<void>;
|
|
65
80
|
watchForChanges({ logChanges, onChange, syncAll, }?: {
|
|
66
|
-
logChanges?: boolean
|
|
67
|
-
onChange?: (
|
|
68
|
-
syncAll?: boolean
|
|
81
|
+
logChanges?: boolean;
|
|
82
|
+
onChange?: () => void;
|
|
83
|
+
syncAll?: boolean;
|
|
69
84
|
}): Promise<void>;
|
|
70
85
|
wranglerDeployFrontend(projectType: FrontendProjectType): Promise<string>;
|
|
71
86
|
private confirmRemoveInstalledApp;
|