@bigcommerce/stencil-cli 8.7.0 → 8.8.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/lib/BuildConfigManager.js +32 -3
- package/lib/stencil-bundle.js +2 -1
- package/lib/stencil-start.js +1 -0
- package/package.json +1 -1
|
@@ -6,6 +6,11 @@ import { createRequire } from 'node:module';
|
|
|
6
6
|
import { THEME_PATH } from '../constants.js';
|
|
7
7
|
|
|
8
8
|
const require = createRequire(import.meta.url);
|
|
9
|
+
const isJest = typeof process !== 'undefined' && 'JEST_WORKER_ID' in process.env;
|
|
10
|
+
|
|
11
|
+
const cornerstoneConfigLink = isJest
|
|
12
|
+
? 'https://raw.githubusercontent.com/bigcommerce/stencil-cli/master/test/_mocks/build-config/valid-config/stencil.conf.cjs'
|
|
13
|
+
: 'https://raw.githubusercontent.com/bigcommerce/cornerstone/master/stencil.conf.cjs';
|
|
9
14
|
|
|
10
15
|
class BuildConfigManager {
|
|
11
16
|
constructor({ workDir = THEME_PATH, fs = fsModule, timeout = 20000 } = {}) {
|
|
@@ -19,7 +24,10 @@ class BuildConfigManager {
|
|
|
19
24
|
this._worker = null;
|
|
20
25
|
this._workerIsReady = false;
|
|
21
26
|
this.timeout = timeout;
|
|
22
|
-
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async initConfig() {
|
|
30
|
+
const config = await this._getConfig(this._buildConfigPath, this._oldBuildConfigPath);
|
|
23
31
|
this.development = config.development || this._devWorker;
|
|
24
32
|
this.production = config.production || this._prodWorker;
|
|
25
33
|
this.watchOptions = config.watchOptions;
|
|
@@ -42,7 +50,7 @@ class BuildConfigManager {
|
|
|
42
50
|
this._worker.kill(signal);
|
|
43
51
|
}
|
|
44
52
|
|
|
45
|
-
_getConfig(configPath, oldConfigPath) {
|
|
53
|
+
async _getConfig(configPath, oldConfigPath) {
|
|
46
54
|
if (this._fs.existsSync(configPath)) {
|
|
47
55
|
// eslint-disable-next-line import/no-dynamic-require
|
|
48
56
|
return require(configPath);
|
|
@@ -52,7 +60,28 @@ class BuildConfigManager {
|
|
|
52
60
|
// eslint-disable-next-line import/no-dynamic-require
|
|
53
61
|
return require(configPath);
|
|
54
62
|
}
|
|
55
|
-
|
|
63
|
+
|
|
64
|
+
// Fallback to cornerstone default stencil.conf.cjs
|
|
65
|
+
const content = await this.downloadFileFromGitHub(cornerstoneConfigLink);
|
|
66
|
+
this._fs.writeFileSync(configPath, content);
|
|
67
|
+
|
|
68
|
+
// eslint-disable-next-line import/no-dynamic-require
|
|
69
|
+
return require(configPath);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async downloadFileFromGitHub(rawUrl) {
|
|
73
|
+
try {
|
|
74
|
+
const response = await fetch(rawUrl);
|
|
75
|
+
|
|
76
|
+
if (!response.ok) {
|
|
77
|
+
console.log(`Failed to fetch file from ${rawUrl}: ${response.statusText}`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return response.text();
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.error('Failed to fetch stencil.conf.cjs:', error);
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
56
85
|
}
|
|
57
86
|
|
|
58
87
|
_moveOldConfig(newPath, oldPath) {
|
package/lib/stencil-bundle.js
CHANGED
|
@@ -68,8 +68,9 @@ class Bundle {
|
|
|
68
68
|
tasks.schemaTranslations = this.assembleSchemaTranslations.bind(this);
|
|
69
69
|
tasks.stencilContext = this.assembleStencilContextTask.bind(this);
|
|
70
70
|
if (typeof buildConfigManager.production === 'function') {
|
|
71
|
-
tasks.theme = (callback) => {
|
|
71
|
+
tasks.theme = async (callback) => {
|
|
72
72
|
console.log('Theme task Started...');
|
|
73
|
+
await buildConfigManager.initConfig();
|
|
73
74
|
buildConfigManager.initWorker().production((err) => {
|
|
74
75
|
if (err) {
|
|
75
76
|
return callback(err);
|
package/lib/stencil-start.js
CHANGED
|
@@ -233,6 +233,7 @@ class StencilStart {
|
|
|
233
233
|
}
|
|
234
234
|
});
|
|
235
235
|
if (this._buildConfigManager.development) {
|
|
236
|
+
await this._buildConfigManager.initConfig();
|
|
236
237
|
this._buildConfigManager.initWorker().development(this._browserSync);
|
|
237
238
|
}
|
|
238
239
|
await this.checkLangFiles(langsPath, this._storeSettingsLocale.default_shopper_language);
|