@wordpress-flow/cli 1.1.3 → 1.1.4
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/index.js +1511 -937
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3337,401 +3337,6 @@ var require_source = __commonJS((exports, module) => {
|
|
|
3337
3337
|
module.exports = chalk;
|
|
3338
3338
|
});
|
|
3339
3339
|
|
|
3340
|
-
// ../../node_modules/dotenv/package.json
|
|
3341
|
-
var require_package = __commonJS((exports, module) => {
|
|
3342
|
-
module.exports = {
|
|
3343
|
-
name: "dotenv",
|
|
3344
|
-
version: "17.2.3",
|
|
3345
|
-
description: "Loads environment variables from .env file",
|
|
3346
|
-
main: "lib/main.js",
|
|
3347
|
-
types: "lib/main.d.ts",
|
|
3348
|
-
exports: {
|
|
3349
|
-
".": {
|
|
3350
|
-
types: "./lib/main.d.ts",
|
|
3351
|
-
require: "./lib/main.js",
|
|
3352
|
-
default: "./lib/main.js"
|
|
3353
|
-
},
|
|
3354
|
-
"./config": "./config.js",
|
|
3355
|
-
"./config.js": "./config.js",
|
|
3356
|
-
"./lib/env-options": "./lib/env-options.js",
|
|
3357
|
-
"./lib/env-options.js": "./lib/env-options.js",
|
|
3358
|
-
"./lib/cli-options": "./lib/cli-options.js",
|
|
3359
|
-
"./lib/cli-options.js": "./lib/cli-options.js",
|
|
3360
|
-
"./package.json": "./package.json"
|
|
3361
|
-
},
|
|
3362
|
-
scripts: {
|
|
3363
|
-
"dts-check": "tsc --project tests/types/tsconfig.json",
|
|
3364
|
-
lint: "standard",
|
|
3365
|
-
pretest: "npm run lint && npm run dts-check",
|
|
3366
|
-
test: "tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000",
|
|
3367
|
-
"test:coverage": "tap run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",
|
|
3368
|
-
prerelease: "npm test",
|
|
3369
|
-
release: "standard-version"
|
|
3370
|
-
},
|
|
3371
|
-
repository: {
|
|
3372
|
-
type: "git",
|
|
3373
|
-
url: "git://github.com/motdotla/dotenv.git"
|
|
3374
|
-
},
|
|
3375
|
-
homepage: "https://github.com/motdotla/dotenv#readme",
|
|
3376
|
-
funding: "https://dotenvx.com",
|
|
3377
|
-
keywords: [
|
|
3378
|
-
"dotenv",
|
|
3379
|
-
"env",
|
|
3380
|
-
".env",
|
|
3381
|
-
"environment",
|
|
3382
|
-
"variables",
|
|
3383
|
-
"config",
|
|
3384
|
-
"settings"
|
|
3385
|
-
],
|
|
3386
|
-
readmeFilename: "README.md",
|
|
3387
|
-
license: "BSD-2-Clause",
|
|
3388
|
-
devDependencies: {
|
|
3389
|
-
"@types/node": "^18.11.3",
|
|
3390
|
-
decache: "^4.6.2",
|
|
3391
|
-
sinon: "^14.0.1",
|
|
3392
|
-
standard: "^17.0.0",
|
|
3393
|
-
"standard-version": "^9.5.0",
|
|
3394
|
-
tap: "^19.2.0",
|
|
3395
|
-
typescript: "^4.8.4"
|
|
3396
|
-
},
|
|
3397
|
-
engines: {
|
|
3398
|
-
node: ">=12"
|
|
3399
|
-
},
|
|
3400
|
-
browser: {
|
|
3401
|
-
fs: false
|
|
3402
|
-
}
|
|
3403
|
-
};
|
|
3404
|
-
});
|
|
3405
|
-
|
|
3406
|
-
// ../../node_modules/dotenv/lib/main.js
|
|
3407
|
-
var require_main = __commonJS((exports, module) => {
|
|
3408
|
-
var fs2 = __require("fs");
|
|
3409
|
-
var path2 = __require("path");
|
|
3410
|
-
var os = __require("os");
|
|
3411
|
-
var crypto = __require("crypto");
|
|
3412
|
-
var packageJson = require_package();
|
|
3413
|
-
var version = packageJson.version;
|
|
3414
|
-
var TIPS = [
|
|
3415
|
-
"\uD83D\uDD10 encrypt with Dotenvx: https://dotenvx.com",
|
|
3416
|
-
"\uD83D\uDD10 prevent committing .env to code: https://dotenvx.com/precommit",
|
|
3417
|
-
"\uD83D\uDD10 prevent building .env in docker: https://dotenvx.com/prebuild",
|
|
3418
|
-
"\uD83D\uDCE1 add observability to secrets: https://dotenvx.com/ops",
|
|
3419
|
-
"\uD83D\uDC65 sync secrets across teammates & machines: https://dotenvx.com/ops",
|
|
3420
|
-
"\uD83D\uDDC2️ backup and recover secrets: https://dotenvx.com/ops",
|
|
3421
|
-
"✅ audit secrets and track compliance: https://dotenvx.com/ops",
|
|
3422
|
-
"\uD83D\uDD04 add secrets lifecycle management: https://dotenvx.com/ops",
|
|
3423
|
-
"\uD83D\uDD11 add access controls to secrets: https://dotenvx.com/ops",
|
|
3424
|
-
"\uD83D\uDEE0️ run anywhere with `dotenvx run -- yourcommand`",
|
|
3425
|
-
"⚙️ specify custom .env file path with { path: '/custom/path/.env' }",
|
|
3426
|
-
"⚙️ enable debug logging with { debug: true }",
|
|
3427
|
-
"⚙️ override existing env vars with { override: true }",
|
|
3428
|
-
"⚙️ suppress all logs with { quiet: true }",
|
|
3429
|
-
"⚙️ write to custom object with { processEnv: myObject }",
|
|
3430
|
-
"⚙️ load multiple .env files with { path: ['.env.local', '.env'] }"
|
|
3431
|
-
];
|
|
3432
|
-
function _getRandomTip() {
|
|
3433
|
-
return TIPS[Math.floor(Math.random() * TIPS.length)];
|
|
3434
|
-
}
|
|
3435
|
-
function parseBoolean(value) {
|
|
3436
|
-
if (typeof value === "string") {
|
|
3437
|
-
return !["false", "0", "no", "off", ""].includes(value.toLowerCase());
|
|
3438
|
-
}
|
|
3439
|
-
return Boolean(value);
|
|
3440
|
-
}
|
|
3441
|
-
function supportsAnsi() {
|
|
3442
|
-
return process.stdout.isTTY;
|
|
3443
|
-
}
|
|
3444
|
-
function dim(text) {
|
|
3445
|
-
return supportsAnsi() ? `\x1B[2m${text}\x1B[0m` : text;
|
|
3446
|
-
}
|
|
3447
|
-
var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
|
3448
|
-
function parse(src) {
|
|
3449
|
-
const obj = {};
|
|
3450
|
-
let lines = src.toString();
|
|
3451
|
-
lines = lines.replace(/\r\n?/mg, `
|
|
3452
|
-
`);
|
|
3453
|
-
let match;
|
|
3454
|
-
while ((match = LINE.exec(lines)) != null) {
|
|
3455
|
-
const key = match[1];
|
|
3456
|
-
let value = match[2] || "";
|
|
3457
|
-
value = value.trim();
|
|
3458
|
-
const maybeQuote = value[0];
|
|
3459
|
-
value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
|
|
3460
|
-
if (maybeQuote === '"') {
|
|
3461
|
-
value = value.replace(/\\n/g, `
|
|
3462
|
-
`);
|
|
3463
|
-
value = value.replace(/\\r/g, "\r");
|
|
3464
|
-
}
|
|
3465
|
-
obj[key] = value;
|
|
3466
|
-
}
|
|
3467
|
-
return obj;
|
|
3468
|
-
}
|
|
3469
|
-
function _parseVault(options) {
|
|
3470
|
-
options = options || {};
|
|
3471
|
-
const vaultPath = _vaultPath(options);
|
|
3472
|
-
options.path = vaultPath;
|
|
3473
|
-
const result2 = DotenvModule.configDotenv(options);
|
|
3474
|
-
if (!result2.parsed) {
|
|
3475
|
-
const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
|
|
3476
|
-
err.code = "MISSING_DATA";
|
|
3477
|
-
throw err;
|
|
3478
|
-
}
|
|
3479
|
-
const keys = _dotenvKey(options).split(",");
|
|
3480
|
-
const length = keys.length;
|
|
3481
|
-
let decrypted;
|
|
3482
|
-
for (let i = 0;i < length; i++) {
|
|
3483
|
-
try {
|
|
3484
|
-
const key = keys[i].trim();
|
|
3485
|
-
const attrs = _instructions(result2, key);
|
|
3486
|
-
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
|
|
3487
|
-
break;
|
|
3488
|
-
} catch (error) {
|
|
3489
|
-
if (i + 1 >= length) {
|
|
3490
|
-
throw error;
|
|
3491
|
-
}
|
|
3492
|
-
}
|
|
3493
|
-
}
|
|
3494
|
-
return DotenvModule.parse(decrypted);
|
|
3495
|
-
}
|
|
3496
|
-
function _warn(message) {
|
|
3497
|
-
console.error(`[dotenv@${version}][WARN] ${message}`);
|
|
3498
|
-
}
|
|
3499
|
-
function _debug(message) {
|
|
3500
|
-
console.log(`[dotenv@${version}][DEBUG] ${message}`);
|
|
3501
|
-
}
|
|
3502
|
-
function _log(message) {
|
|
3503
|
-
console.log(`[dotenv@${version}] ${message}`);
|
|
3504
|
-
}
|
|
3505
|
-
function _dotenvKey(options) {
|
|
3506
|
-
if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
|
|
3507
|
-
return options.DOTENV_KEY;
|
|
3508
|
-
}
|
|
3509
|
-
if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
|
|
3510
|
-
return process.env.DOTENV_KEY;
|
|
3511
|
-
}
|
|
3512
|
-
return "";
|
|
3513
|
-
}
|
|
3514
|
-
function _instructions(result2, dotenvKey) {
|
|
3515
|
-
let uri;
|
|
3516
|
-
try {
|
|
3517
|
-
uri = new URL(dotenvKey);
|
|
3518
|
-
} catch (error) {
|
|
3519
|
-
if (error.code === "ERR_INVALID_URL") {
|
|
3520
|
-
const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
|
|
3521
|
-
err.code = "INVALID_DOTENV_KEY";
|
|
3522
|
-
throw err;
|
|
3523
|
-
}
|
|
3524
|
-
throw error;
|
|
3525
|
-
}
|
|
3526
|
-
const key = uri.password;
|
|
3527
|
-
if (!key) {
|
|
3528
|
-
const err = new Error("INVALID_DOTENV_KEY: Missing key part");
|
|
3529
|
-
err.code = "INVALID_DOTENV_KEY";
|
|
3530
|
-
throw err;
|
|
3531
|
-
}
|
|
3532
|
-
const environment = uri.searchParams.get("environment");
|
|
3533
|
-
if (!environment) {
|
|
3534
|
-
const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
|
|
3535
|
-
err.code = "INVALID_DOTENV_KEY";
|
|
3536
|
-
throw err;
|
|
3537
|
-
}
|
|
3538
|
-
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
|
|
3539
|
-
const ciphertext = result2.parsed[environmentKey];
|
|
3540
|
-
if (!ciphertext) {
|
|
3541
|
-
const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
|
|
3542
|
-
err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
|
|
3543
|
-
throw err;
|
|
3544
|
-
}
|
|
3545
|
-
return { ciphertext, key };
|
|
3546
|
-
}
|
|
3547
|
-
function _vaultPath(options) {
|
|
3548
|
-
let possibleVaultPath = null;
|
|
3549
|
-
if (options && options.path && options.path.length > 0) {
|
|
3550
|
-
if (Array.isArray(options.path)) {
|
|
3551
|
-
for (const filepath of options.path) {
|
|
3552
|
-
if (fs2.existsSync(filepath)) {
|
|
3553
|
-
possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
|
3554
|
-
}
|
|
3555
|
-
}
|
|
3556
|
-
} else {
|
|
3557
|
-
possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
|
3558
|
-
}
|
|
3559
|
-
} else {
|
|
3560
|
-
possibleVaultPath = path2.resolve(process.cwd(), ".env.vault");
|
|
3561
|
-
}
|
|
3562
|
-
if (fs2.existsSync(possibleVaultPath)) {
|
|
3563
|
-
return possibleVaultPath;
|
|
3564
|
-
}
|
|
3565
|
-
return null;
|
|
3566
|
-
}
|
|
3567
|
-
function _resolveHome(envPath) {
|
|
3568
|
-
return envPath[0] === "~" ? path2.join(os.homedir(), envPath.slice(1)) : envPath;
|
|
3569
|
-
}
|
|
3570
|
-
function _configVault(options) {
|
|
3571
|
-
const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
|
|
3572
|
-
const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || options && options.quiet);
|
|
3573
|
-
if (debug || !quiet) {
|
|
3574
|
-
_log("Loading env from encrypted .env.vault");
|
|
3575
|
-
}
|
|
3576
|
-
const parsed = DotenvModule._parseVault(options);
|
|
3577
|
-
let processEnv = process.env;
|
|
3578
|
-
if (options && options.processEnv != null) {
|
|
3579
|
-
processEnv = options.processEnv;
|
|
3580
|
-
}
|
|
3581
|
-
DotenvModule.populate(processEnv, parsed, options);
|
|
3582
|
-
return { parsed };
|
|
3583
|
-
}
|
|
3584
|
-
function configDotenv(options) {
|
|
3585
|
-
const dotenvPath = path2.resolve(process.cwd(), ".env");
|
|
3586
|
-
let encoding = "utf8";
|
|
3587
|
-
let processEnv = process.env;
|
|
3588
|
-
if (options && options.processEnv != null) {
|
|
3589
|
-
processEnv = options.processEnv;
|
|
3590
|
-
}
|
|
3591
|
-
let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || options && options.debug);
|
|
3592
|
-
let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || options && options.quiet);
|
|
3593
|
-
if (options && options.encoding) {
|
|
3594
|
-
encoding = options.encoding;
|
|
3595
|
-
} else {
|
|
3596
|
-
if (debug) {
|
|
3597
|
-
_debug("No encoding is specified. UTF-8 is used by default");
|
|
3598
|
-
}
|
|
3599
|
-
}
|
|
3600
|
-
let optionPaths = [dotenvPath];
|
|
3601
|
-
if (options && options.path) {
|
|
3602
|
-
if (!Array.isArray(options.path)) {
|
|
3603
|
-
optionPaths = [_resolveHome(options.path)];
|
|
3604
|
-
} else {
|
|
3605
|
-
optionPaths = [];
|
|
3606
|
-
for (const filepath of options.path) {
|
|
3607
|
-
optionPaths.push(_resolveHome(filepath));
|
|
3608
|
-
}
|
|
3609
|
-
}
|
|
3610
|
-
}
|
|
3611
|
-
let lastError;
|
|
3612
|
-
const parsedAll = {};
|
|
3613
|
-
for (const path3 of optionPaths) {
|
|
3614
|
-
try {
|
|
3615
|
-
const parsed = DotenvModule.parse(fs2.readFileSync(path3, { encoding }));
|
|
3616
|
-
DotenvModule.populate(parsedAll, parsed, options);
|
|
3617
|
-
} catch (e) {
|
|
3618
|
-
if (debug) {
|
|
3619
|
-
_debug(`Failed to load ${path3} ${e.message}`);
|
|
3620
|
-
}
|
|
3621
|
-
lastError = e;
|
|
3622
|
-
}
|
|
3623
|
-
}
|
|
3624
|
-
const populated = DotenvModule.populate(processEnv, parsedAll, options);
|
|
3625
|
-
debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
|
|
3626
|
-
quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
|
|
3627
|
-
if (debug || !quiet) {
|
|
3628
|
-
const keysCount = Object.keys(populated).length;
|
|
3629
|
-
const shortPaths = [];
|
|
3630
|
-
for (const filePath2 of optionPaths) {
|
|
3631
|
-
try {
|
|
3632
|
-
const relative = path2.relative(process.cwd(), filePath2);
|
|
3633
|
-
shortPaths.push(relative);
|
|
3634
|
-
} catch (e) {
|
|
3635
|
-
if (debug) {
|
|
3636
|
-
_debug(`Failed to load ${filePath2} ${e.message}`);
|
|
3637
|
-
}
|
|
3638
|
-
lastError = e;
|
|
3639
|
-
}
|
|
3640
|
-
}
|
|
3641
|
-
_log(`injecting env (${keysCount}) from ${shortPaths.join(",")} ${dim(`-- tip: ${_getRandomTip()}`)}`);
|
|
3642
|
-
}
|
|
3643
|
-
if (lastError) {
|
|
3644
|
-
return { parsed: parsedAll, error: lastError };
|
|
3645
|
-
} else {
|
|
3646
|
-
return { parsed: parsedAll };
|
|
3647
|
-
}
|
|
3648
|
-
}
|
|
3649
|
-
function config(options) {
|
|
3650
|
-
if (_dotenvKey(options).length === 0) {
|
|
3651
|
-
return DotenvModule.configDotenv(options);
|
|
3652
|
-
}
|
|
3653
|
-
const vaultPath = _vaultPath(options);
|
|
3654
|
-
if (!vaultPath) {
|
|
3655
|
-
_warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
|
|
3656
|
-
return DotenvModule.configDotenv(options);
|
|
3657
|
-
}
|
|
3658
|
-
return DotenvModule._configVault(options);
|
|
3659
|
-
}
|
|
3660
|
-
function decrypt(encrypted, keyStr) {
|
|
3661
|
-
const key = Buffer.from(keyStr.slice(-64), "hex");
|
|
3662
|
-
let ciphertext = Buffer.from(encrypted, "base64");
|
|
3663
|
-
const nonce = ciphertext.subarray(0, 12);
|
|
3664
|
-
const authTag = ciphertext.subarray(-16);
|
|
3665
|
-
ciphertext = ciphertext.subarray(12, -16);
|
|
3666
|
-
try {
|
|
3667
|
-
const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
|
|
3668
|
-
aesgcm.setAuthTag(authTag);
|
|
3669
|
-
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
|
|
3670
|
-
} catch (error) {
|
|
3671
|
-
const isRange = error instanceof RangeError;
|
|
3672
|
-
const invalidKeyLength = error.message === "Invalid key length";
|
|
3673
|
-
const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
|
|
3674
|
-
if (isRange || invalidKeyLength) {
|
|
3675
|
-
const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
|
|
3676
|
-
err.code = "INVALID_DOTENV_KEY";
|
|
3677
|
-
throw err;
|
|
3678
|
-
} else if (decryptionFailed) {
|
|
3679
|
-
const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
|
|
3680
|
-
err.code = "DECRYPTION_FAILED";
|
|
3681
|
-
throw err;
|
|
3682
|
-
} else {
|
|
3683
|
-
throw error;
|
|
3684
|
-
}
|
|
3685
|
-
}
|
|
3686
|
-
}
|
|
3687
|
-
function populate(processEnv, parsed, options = {}) {
|
|
3688
|
-
const debug = Boolean(options && options.debug);
|
|
3689
|
-
const override = Boolean(options && options.override);
|
|
3690
|
-
const populated = {};
|
|
3691
|
-
if (typeof parsed !== "object") {
|
|
3692
|
-
const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
|
|
3693
|
-
err.code = "OBJECT_REQUIRED";
|
|
3694
|
-
throw err;
|
|
3695
|
-
}
|
|
3696
|
-
for (const key of Object.keys(parsed)) {
|
|
3697
|
-
if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
|
|
3698
|
-
if (override === true) {
|
|
3699
|
-
processEnv[key] = parsed[key];
|
|
3700
|
-
populated[key] = parsed[key];
|
|
3701
|
-
}
|
|
3702
|
-
if (debug) {
|
|
3703
|
-
if (override === true) {
|
|
3704
|
-
_debug(`"${key}" is already defined and WAS overwritten`);
|
|
3705
|
-
} else {
|
|
3706
|
-
_debug(`"${key}" is already defined and was NOT overwritten`);
|
|
3707
|
-
}
|
|
3708
|
-
}
|
|
3709
|
-
} else {
|
|
3710
|
-
processEnv[key] = parsed[key];
|
|
3711
|
-
populated[key] = parsed[key];
|
|
3712
|
-
}
|
|
3713
|
-
}
|
|
3714
|
-
return populated;
|
|
3715
|
-
}
|
|
3716
|
-
var DotenvModule = {
|
|
3717
|
-
configDotenv,
|
|
3718
|
-
_configVault,
|
|
3719
|
-
_parseVault,
|
|
3720
|
-
config,
|
|
3721
|
-
decrypt,
|
|
3722
|
-
parse,
|
|
3723
|
-
populate
|
|
3724
|
-
};
|
|
3725
|
-
exports.configDotenv = DotenvModule.configDotenv;
|
|
3726
|
-
exports._configVault = DotenvModule._configVault;
|
|
3727
|
-
exports._parseVault = DotenvModule._parseVault;
|
|
3728
|
-
exports.config = DotenvModule.config;
|
|
3729
|
-
exports.decrypt = DotenvModule.decrypt;
|
|
3730
|
-
exports.parse = DotenvModule.parse;
|
|
3731
|
-
exports.populate = DotenvModule.populate;
|
|
3732
|
-
module.exports = DotenvModule;
|
|
3733
|
-
});
|
|
3734
|
-
|
|
3735
3340
|
// ../../node_modules/delayed-stream/lib/delayed_stream.js
|
|
3736
3341
|
var require_delayed_stream = __commonJS((exports, module) => {
|
|
3737
3342
|
var Stream = __require("stream").Stream;
|
|
@@ -15441,16 +15046,16 @@ var require_parser_cache = __commonJS((exports, module) => {
|
|
|
15441
15046
|
var parserCache = createLRU({
|
|
15442
15047
|
max: 15000
|
|
15443
15048
|
});
|
|
15444
|
-
function keyFromFields(type, fields, options,
|
|
15049
|
+
function keyFromFields(type, fields, options, config) {
|
|
15445
15050
|
const res = [
|
|
15446
15051
|
type,
|
|
15447
15052
|
typeof options.nestTables,
|
|
15448
15053
|
options.nestTables,
|
|
15449
15054
|
Boolean(options.rowsAsArray),
|
|
15450
|
-
Boolean(options.supportBigNumbers ||
|
|
15451
|
-
Boolean(options.bigNumberStrings ||
|
|
15055
|
+
Boolean(options.supportBigNumbers || config.supportBigNumbers),
|
|
15056
|
+
Boolean(options.bigNumberStrings || config.bigNumberStrings),
|
|
15452
15057
|
typeof options.typeCast === "boolean" ? options.typeCast : typeof options.typeCast,
|
|
15453
|
-
options.timezone ||
|
|
15058
|
+
options.timezone || config.timezone,
|
|
15454
15059
|
Boolean(options.decimalNumbers),
|
|
15455
15060
|
options.dateStrings
|
|
15456
15061
|
];
|
|
@@ -15468,13 +15073,13 @@ var require_parser_cache = __commonJS((exports, module) => {
|
|
|
15468
15073
|
}
|
|
15469
15074
|
return JSON.stringify(res, null, 0);
|
|
15470
15075
|
}
|
|
15471
|
-
function getParser(type, fields, options,
|
|
15472
|
-
const key = keyFromFields(type, fields, options,
|
|
15076
|
+
function getParser(type, fields, options, config, compiler) {
|
|
15077
|
+
const key = keyFromFields(type, fields, options, config);
|
|
15473
15078
|
let parser = parserCache.get(key);
|
|
15474
15079
|
if (parser) {
|
|
15475
15080
|
return parser;
|
|
15476
15081
|
}
|
|
15477
|
-
parser = compiler(fields, options,
|
|
15082
|
+
parser = compiler(fields, options, config);
|
|
15478
15083
|
parserCache.set(key, parser);
|
|
15479
15084
|
return parser;
|
|
15480
15085
|
}
|
|
@@ -28611,11 +28216,11 @@ var require_text_parser = __commonJS((exports, module) => {
|
|
|
28611
28216
|
for (const t in Types) {
|
|
28612
28217
|
typeNames[Types[t]] = t;
|
|
28613
28218
|
}
|
|
28614
|
-
function readCodeFor(type, charset, encodingExpr,
|
|
28615
|
-
const supportBigNumbers = Boolean(options.supportBigNumbers ||
|
|
28616
|
-
const bigNumberStrings = Boolean(options.bigNumberStrings ||
|
|
28617
|
-
const timezone = options.timezone ||
|
|
28618
|
-
const dateStrings = options.dateStrings ||
|
|
28219
|
+
function readCodeFor(type, charset, encodingExpr, config, options) {
|
|
28220
|
+
const supportBigNumbers = Boolean(options.supportBigNumbers || config.supportBigNumbers);
|
|
28221
|
+
const bigNumberStrings = Boolean(options.bigNumberStrings || config.bigNumberStrings);
|
|
28222
|
+
const timezone = options.timezone || config.timezone;
|
|
28223
|
+
const dateStrings = options.dateStrings || config.dateStrings;
|
|
28619
28224
|
switch (type) {
|
|
28620
28225
|
case Types.TINY:
|
|
28621
28226
|
case Types.SHORT:
|
|
@@ -28635,7 +28240,7 @@ var require_text_parser = __commonJS((exports, module) => {
|
|
|
28635
28240
|
return "packet.readLengthCodedNumber()";
|
|
28636
28241
|
case Types.DECIMAL:
|
|
28637
28242
|
case Types.NEWDECIMAL:
|
|
28638
|
-
if (
|
|
28243
|
+
if (config.decimalNumbers) {
|
|
28639
28244
|
return "packet.parseLengthCodedFloat()";
|
|
28640
28245
|
}
|
|
28641
28246
|
return 'packet.readLengthCodedString("ascii")';
|
|
@@ -28657,7 +28262,7 @@ var require_text_parser = __commonJS((exports, module) => {
|
|
|
28657
28262
|
case Types.VECTOR:
|
|
28658
28263
|
return "packet.parseVector()";
|
|
28659
28264
|
case Types.JSON:
|
|
28660
|
-
return
|
|
28265
|
+
return config.jsonStrings ? 'packet.readLengthCodedString("utf8")' : 'JSON.parse(packet.readLengthCodedString("utf8"))';
|
|
28661
28266
|
default:
|
|
28662
28267
|
if (charset === Charsets.BINARY) {
|
|
28663
28268
|
return "packet.readLengthCodedBuffer()";
|
|
@@ -28665,9 +28270,9 @@ var require_text_parser = __commonJS((exports, module) => {
|
|
|
28665
28270
|
return `packet.readLengthCodedString(${encodingExpr})`;
|
|
28666
28271
|
}
|
|
28667
28272
|
}
|
|
28668
|
-
function compile(fields, options,
|
|
28669
|
-
if (typeof
|
|
28670
|
-
options.typeCast =
|
|
28273
|
+
function compile(fields, options, config) {
|
|
28274
|
+
if (typeof config.typeCast === "function" && typeof options.typeCast !== "function") {
|
|
28275
|
+
options.typeCast = config.typeCast;
|
|
28671
28276
|
}
|
|
28672
28277
|
function wrap(field, _this) {
|
|
28673
28278
|
return {
|
|
@@ -28738,7 +28343,7 @@ var require_text_parser = __commonJS((exports, module) => {
|
|
|
28738
28343
|
parserFn(`${lvalue} = packet.readLengthCodedBuffer();`);
|
|
28739
28344
|
} else {
|
|
28740
28345
|
const encodingExpr = `fields[${i}].encoding`;
|
|
28741
|
-
const readCode = readCodeFor(fields[i].columnType, fields[i].characterSet, encodingExpr,
|
|
28346
|
+
const readCode = readCodeFor(fields[i].columnType, fields[i].characterSet, encodingExpr, config, options);
|
|
28742
28347
|
if (typeof options.typeCast === "function") {
|
|
28743
28348
|
parserFn(`${lvalue} = options.typeCast(this.wrap${i}, function() { return ${readCode} });`);
|
|
28744
28349
|
} else {
|
|
@@ -28749,7 +28354,7 @@ var require_text_parser = __commonJS((exports, module) => {
|
|
|
28749
28354
|
parserFn("return result;");
|
|
28750
28355
|
parserFn("}");
|
|
28751
28356
|
parserFn("};")("})()");
|
|
28752
|
-
if (
|
|
28357
|
+
if (config.debug) {
|
|
28753
28358
|
helpers.printDebugWithCode("Compiled text protocol row parser", parserFn.toString());
|
|
28754
28359
|
}
|
|
28755
28360
|
if (typeof options.typeCast === "function") {
|
|
@@ -28757,8 +28362,8 @@ var require_text_parser = __commonJS((exports, module) => {
|
|
|
28757
28362
|
}
|
|
28758
28363
|
return parserFn.toFunction();
|
|
28759
28364
|
}
|
|
28760
|
-
function getTextParser(fields, options,
|
|
28761
|
-
return parserCache.getParser("text", fields, options,
|
|
28365
|
+
function getTextParser(fields, options, config) {
|
|
28366
|
+
return parserCache.getParser("text", fields, options, config, compile);
|
|
28762
28367
|
}
|
|
28763
28368
|
module.exports = getTextParser;
|
|
28764
28369
|
});
|
|
@@ -28772,11 +28377,11 @@ var require_static_text_parser = __commonJS((exports, module) => {
|
|
|
28772
28377
|
for (const t in Types) {
|
|
28773
28378
|
typeNames[Types[t]] = t;
|
|
28774
28379
|
}
|
|
28775
|
-
function readField({ packet, type, charset, encoding, config
|
|
28776
|
-
const supportBigNumbers = Boolean(options.supportBigNumbers ||
|
|
28777
|
-
const bigNumberStrings = Boolean(options.bigNumberStrings ||
|
|
28778
|
-
const timezone = options.timezone ||
|
|
28779
|
-
const dateStrings = options.dateStrings ||
|
|
28380
|
+
function readField({ packet, type, charset, encoding, config, options }) {
|
|
28381
|
+
const supportBigNumbers = Boolean(options.supportBigNumbers || config.supportBigNumbers);
|
|
28382
|
+
const bigNumberStrings = Boolean(options.bigNumberStrings || config.bigNumberStrings);
|
|
28383
|
+
const timezone = options.timezone || config.timezone;
|
|
28384
|
+
const dateStrings = options.dateStrings || config.dateStrings;
|
|
28780
28385
|
switch (type) {
|
|
28781
28386
|
case Types.TINY:
|
|
28782
28387
|
case Types.SHORT:
|
|
@@ -28795,7 +28400,7 @@ var require_static_text_parser = __commonJS((exports, module) => {
|
|
|
28795
28400
|
case Types.NULL:
|
|
28796
28401
|
case Types.DECIMAL:
|
|
28797
28402
|
case Types.NEWDECIMAL:
|
|
28798
|
-
if (
|
|
28403
|
+
if (config.decimalNumbers) {
|
|
28799
28404
|
return packet.parseLengthCodedFloat();
|
|
28800
28405
|
}
|
|
28801
28406
|
return packet.readLengthCodedString("ascii");
|
|
@@ -28817,7 +28422,7 @@ var require_static_text_parser = __commonJS((exports, module) => {
|
|
|
28817
28422
|
case Types.VECTOR:
|
|
28818
28423
|
return packet.parseVector();
|
|
28819
28424
|
case Types.JSON:
|
|
28820
|
-
return
|
|
28425
|
+
return config.jsonStrings ? packet.readLengthCodedString("utf8") : JSON.parse(packet.readLengthCodedString("utf8"));
|
|
28821
28426
|
default:
|
|
28822
28427
|
if (charset === Charsets.BINARY) {
|
|
28823
28428
|
return packet.readLengthCodedBuffer();
|
|
@@ -28846,19 +28451,19 @@ var require_static_text_parser = __commonJS((exports, module) => {
|
|
|
28846
28451
|
}
|
|
28847
28452
|
};
|
|
28848
28453
|
}
|
|
28849
|
-
function getTextParser(_fields, _options,
|
|
28454
|
+
function getTextParser(_fields, _options, config) {
|
|
28850
28455
|
return {
|
|
28851
28456
|
next(packet, fields, options) {
|
|
28852
28457
|
const result2 = options.rowsAsArray ? [] : {};
|
|
28853
28458
|
for (let i = 0;i < fields.length; i++) {
|
|
28854
28459
|
const field = fields[i];
|
|
28855
|
-
const typeCast = options.typeCast ? options.typeCast :
|
|
28460
|
+
const typeCast = options.typeCast ? options.typeCast : config.typeCast;
|
|
28856
28461
|
const next = () => readField({
|
|
28857
28462
|
packet,
|
|
28858
28463
|
type: field.columnType,
|
|
28859
28464
|
encoding: field.encoding,
|
|
28860
28465
|
charset: field.characterSet,
|
|
28861
|
-
config
|
|
28466
|
+
config,
|
|
28862
28467
|
options
|
|
28863
28468
|
});
|
|
28864
28469
|
let value;
|
|
@@ -29216,11 +28821,11 @@ var require_binary_parser = __commonJS((exports, module) => {
|
|
|
29216
28821
|
for (const t in Types) {
|
|
29217
28822
|
typeNames[Types[t]] = t;
|
|
29218
28823
|
}
|
|
29219
|
-
function readCodeFor(field,
|
|
29220
|
-
const supportBigNumbers = Boolean(options.supportBigNumbers ||
|
|
29221
|
-
const bigNumberStrings = Boolean(options.bigNumberStrings ||
|
|
29222
|
-
const timezone = options.timezone ||
|
|
29223
|
-
const dateStrings = options.dateStrings ||
|
|
28824
|
+
function readCodeFor(field, config, options, fieldNum) {
|
|
28825
|
+
const supportBigNumbers = Boolean(options.supportBigNumbers || config.supportBigNumbers);
|
|
28826
|
+
const bigNumberStrings = Boolean(options.bigNumberStrings || config.bigNumberStrings);
|
|
28827
|
+
const timezone = options.timezone || config.timezone;
|
|
28828
|
+
const dateStrings = options.dateStrings || config.dateStrings;
|
|
29224
28829
|
const unsigned = field.flags & FieldFlags.UNSIGNED;
|
|
29225
28830
|
switch (field.columnType) {
|
|
29226
28831
|
case Types.TINY:
|
|
@@ -29250,7 +28855,7 @@ var require_binary_parser = __commonJS((exports, module) => {
|
|
|
29250
28855
|
return "packet.readTimeString()";
|
|
29251
28856
|
case Types.DECIMAL:
|
|
29252
28857
|
case Types.NEWDECIMAL:
|
|
29253
|
-
if (
|
|
28858
|
+
if (config.decimalNumbers) {
|
|
29254
28859
|
return "packet.parseLengthCodedFloat();";
|
|
29255
28860
|
}
|
|
29256
28861
|
return 'packet.readLengthCodedString("ascii");';
|
|
@@ -29259,7 +28864,7 @@ var require_binary_parser = __commonJS((exports, module) => {
|
|
|
29259
28864
|
case Types.VECTOR:
|
|
29260
28865
|
return "packet.parseVector()";
|
|
29261
28866
|
case Types.JSON:
|
|
29262
|
-
return
|
|
28867
|
+
return config.jsonStrings ? 'packet.readLengthCodedString("utf8")' : 'JSON.parse(packet.readLengthCodedString("utf8"));';
|
|
29263
28868
|
case Types.LONGLONG:
|
|
29264
28869
|
if (!supportBigNumbers) {
|
|
29265
28870
|
return unsigned ? "packet.readInt64JSNumber();" : "packet.readSInt64JSNumber();";
|
|
@@ -29275,7 +28880,7 @@ var require_binary_parser = __commonJS((exports, module) => {
|
|
|
29275
28880
|
return `packet.readLengthCodedString(fields[${fieldNum}].encoding)`;
|
|
29276
28881
|
}
|
|
29277
28882
|
}
|
|
29278
|
-
function compile(fields, options,
|
|
28883
|
+
function compile(fields, options, config) {
|
|
29279
28884
|
const parserFn = genFunc();
|
|
29280
28885
|
const nullBitmapLength = Math.floor((fields.length + 7 + 2) / 8);
|
|
29281
28886
|
function wrap(field, packet) {
|
|
@@ -29319,8 +28924,8 @@ var require_binary_parser = __commonJS((exports, module) => {
|
|
|
29319
28924
|
} else {
|
|
29320
28925
|
parserFn("const result = {};");
|
|
29321
28926
|
}
|
|
29322
|
-
if (typeof
|
|
29323
|
-
options.typeCast =
|
|
28927
|
+
if (typeof config.typeCast === "function" && typeof options.typeCast !== "function") {
|
|
28928
|
+
options.typeCast = config.typeCast;
|
|
29324
28929
|
}
|
|
29325
28930
|
parserFn("packet.readInt8();");
|
|
29326
28931
|
for (let i = 0;i < nullBitmapLength; ++i) {
|
|
@@ -29352,7 +28957,7 @@ var require_binary_parser = __commonJS((exports, module) => {
|
|
|
29352
28957
|
} else {
|
|
29353
28958
|
const fieldWrapperVar = `fieldWrapper${i}`;
|
|
29354
28959
|
parserFn(`const ${fieldWrapperVar} = wrap(fields[${i}], packet);`);
|
|
29355
|
-
const readCode = readCodeFor(fields[i],
|
|
28960
|
+
const readCode = readCodeFor(fields[i], config, options, i);
|
|
29356
28961
|
if (typeof options.typeCast === "function") {
|
|
29357
28962
|
parserFn(`${lvalue} = options.typeCast(${fieldWrapperVar}, function() { return ${readCode} });`);
|
|
29358
28963
|
} else {
|
|
@@ -29369,13 +28974,13 @@ var require_binary_parser = __commonJS((exports, module) => {
|
|
|
29369
28974
|
parserFn("return result;");
|
|
29370
28975
|
parserFn("}");
|
|
29371
28976
|
parserFn("};")("})()");
|
|
29372
|
-
if (
|
|
28977
|
+
if (config.debug) {
|
|
29373
28978
|
helpers.printDebugWithCode("Compiled binary protocol row parser", parserFn.toString());
|
|
29374
28979
|
}
|
|
29375
28980
|
return parserFn.toFunction({ wrap });
|
|
29376
28981
|
}
|
|
29377
|
-
function getBinaryParser(fields, options,
|
|
29378
|
-
return parserCache.getParser("binary", fields, options,
|
|
28982
|
+
function getBinaryParser(fields, options, config) {
|
|
28983
|
+
return parserCache.getParser("binary", fields, options, config, compile);
|
|
29379
28984
|
}
|
|
29380
28985
|
module.exports = getBinaryParser;
|
|
29381
28986
|
});
|
|
@@ -29390,12 +28995,12 @@ var require_static_binary_parser = __commonJS((exports, module) => {
|
|
|
29390
28995
|
for (const t in Types) {
|
|
29391
28996
|
typeNames[Types[t]] = t;
|
|
29392
28997
|
}
|
|
29393
|
-
function getBinaryParser(fields, _options,
|
|
29394
|
-
function readCode(field,
|
|
29395
|
-
const supportBigNumbers = Boolean(options.supportBigNumbers ||
|
|
29396
|
-
const bigNumberStrings = Boolean(options.bigNumberStrings ||
|
|
29397
|
-
const timezone = options.timezone ||
|
|
29398
|
-
const dateStrings = options.dateStrings ||
|
|
28998
|
+
function getBinaryParser(fields, _options, config) {
|
|
28999
|
+
function readCode(field, config2, options, fieldNum, packet) {
|
|
29000
|
+
const supportBigNumbers = Boolean(options.supportBigNumbers || config2.supportBigNumbers);
|
|
29001
|
+
const bigNumberStrings = Boolean(options.bigNumberStrings || config2.bigNumberStrings);
|
|
29002
|
+
const timezone = options.timezone || config2.timezone;
|
|
29003
|
+
const dateStrings = options.dateStrings || config2.dateStrings;
|
|
29399
29004
|
const unsigned = field.flags & FieldFlags.UNSIGNED;
|
|
29400
29005
|
switch (field.columnType) {
|
|
29401
29006
|
case Types.TINY:
|
|
@@ -29422,13 +29027,13 @@ var require_static_binary_parser = __commonJS((exports, module) => {
|
|
|
29422
29027
|
return packet.readTimeString();
|
|
29423
29028
|
case Types.DECIMAL:
|
|
29424
29029
|
case Types.NEWDECIMAL:
|
|
29425
|
-
return
|
|
29030
|
+
return config2.decimalNumbers ? packet.parseLengthCodedFloat() : packet.readLengthCodedString("ascii");
|
|
29426
29031
|
case Types.GEOMETRY:
|
|
29427
29032
|
return packet.parseGeometryValue();
|
|
29428
29033
|
case Types.VECTOR:
|
|
29429
29034
|
return packet.parseVector();
|
|
29430
29035
|
case Types.JSON:
|
|
29431
|
-
return
|
|
29036
|
+
return config2.jsonStrings ? packet.readLengthCodedString("utf8") : JSON.parse(packet.readLengthCodedString("utf8"));
|
|
29432
29037
|
case Types.LONGLONG:
|
|
29433
29038
|
if (!supportBigNumbers)
|
|
29434
29039
|
return unsigned ? packet.readInt64JSNumber() : packet.readSInt64JSNumber();
|
|
@@ -29451,14 +29056,14 @@ var require_static_binary_parser = __commonJS((exports, module) => {
|
|
|
29451
29056
|
let nullByteIndex = 0;
|
|
29452
29057
|
for (let i = 0;i < fields2.length; i++) {
|
|
29453
29058
|
const field = fields2[i];
|
|
29454
|
-
const typeCast = options.typeCast !== undefined ? options.typeCast :
|
|
29059
|
+
const typeCast = options.typeCast !== undefined ? options.typeCast : config.typeCast;
|
|
29455
29060
|
let value;
|
|
29456
29061
|
if (nullBitmaskBytes[nullByteIndex] & currentFieldNullBit) {
|
|
29457
29062
|
value = null;
|
|
29458
29063
|
} else if (options.typeCast === false) {
|
|
29459
29064
|
value = packet.readLengthCodedBuffer();
|
|
29460
29065
|
} else {
|
|
29461
|
-
const next = () => readCode(field,
|
|
29066
|
+
const next = () => readCode(field, config, options, i, packet);
|
|
29462
29067
|
value = typeof typeCast === "function" ? typeCast({
|
|
29463
29068
|
type: typeNames[field.columnType],
|
|
29464
29069
|
length: field.columnLength,
|
|
@@ -30078,7 +29683,7 @@ var require_commands2 = __commonJS((exports, module) => {
|
|
|
30078
29683
|
});
|
|
30079
29684
|
|
|
30080
29685
|
// ../../node_modules/mysql2/package.json
|
|
30081
|
-
var
|
|
29686
|
+
var require_package = __commonJS((exports, module) => {
|
|
30082
29687
|
module.exports = {
|
|
30083
29688
|
name: "mysql2",
|
|
30084
29689
|
version: "3.15.3",
|
|
@@ -33302,7 +32907,7 @@ var require_connection_config = __commonJS((exports, module) => {
|
|
|
33302
32907
|
var { URL: URL2 } = __require("url");
|
|
33303
32908
|
var ClientConstants = require_client();
|
|
33304
32909
|
var Charsets = require_charsets();
|
|
33305
|
-
var { version } =
|
|
32910
|
+
var { version } = require_package();
|
|
33306
32911
|
var SSLProfiles = null;
|
|
33307
32912
|
var validOptions = {
|
|
33308
32913
|
authPlugins: 1,
|
|
@@ -34569,21 +34174,21 @@ var require_named_placeholders = __commonJS((exports, module) => {
|
|
|
34569
34174
|
}
|
|
34570
34175
|
return [query];
|
|
34571
34176
|
}
|
|
34572
|
-
function createCompiler(
|
|
34573
|
-
if (!
|
|
34574
|
-
|
|
34575
|
-
if (!
|
|
34576
|
-
|
|
34177
|
+
function createCompiler(config) {
|
|
34178
|
+
if (!config)
|
|
34179
|
+
config = {};
|
|
34180
|
+
if (!config.placeholder) {
|
|
34181
|
+
config.placeholder = "?";
|
|
34577
34182
|
}
|
|
34578
34183
|
let ncache = 100;
|
|
34579
34184
|
let cache;
|
|
34580
|
-
if (typeof
|
|
34581
|
-
ncache =
|
|
34185
|
+
if (typeof config.cache === "number") {
|
|
34186
|
+
ncache = config.cache;
|
|
34582
34187
|
}
|
|
34583
|
-
if (typeof
|
|
34584
|
-
cache =
|
|
34188
|
+
if (typeof config.cache === "object") {
|
|
34189
|
+
cache = config.cache;
|
|
34585
34190
|
}
|
|
34586
|
-
if (
|
|
34191
|
+
if (config.cache !== false && !cache) {
|
|
34587
34192
|
cache = new (require_lru_cache())({ max: ncache });
|
|
34588
34193
|
}
|
|
34589
34194
|
function toArrayParams(tree, params) {
|
|
@@ -34612,17 +34217,17 @@ var require_named_placeholders = __commonJS((exports, module) => {
|
|
|
34612
34217
|
let unnamed = noTailingSemicolon(tree[0][0]);
|
|
34613
34218
|
for (let i = 1;i < tree[0].length; ++i) {
|
|
34614
34219
|
if (tree[0][i - 1].slice(-1) == ":") {
|
|
34615
|
-
unnamed +=
|
|
34220
|
+
unnamed += config.placeholder;
|
|
34616
34221
|
}
|
|
34617
|
-
unnamed +=
|
|
34222
|
+
unnamed += config.placeholder;
|
|
34618
34223
|
unnamed += noTailingSemicolon(tree[0][i]);
|
|
34619
34224
|
}
|
|
34620
34225
|
const last = tree[0][tree[0].length - 1];
|
|
34621
34226
|
if (tree[0].length == tree[1].length) {
|
|
34622
34227
|
if (last.slice(-1) == ":") {
|
|
34623
|
-
unnamed +=
|
|
34228
|
+
unnamed += config.placeholder;
|
|
34624
34229
|
}
|
|
34625
|
-
unnamed +=
|
|
34230
|
+
unnamed += config.placeholder;
|
|
34626
34231
|
}
|
|
34627
34232
|
return [unnamed, tree[1]];
|
|
34628
34233
|
}
|
|
@@ -35344,10 +34949,10 @@ var require_connection = __commonJS((exports, module) => {
|
|
|
35344
34949
|
this.addCommand = this._addCommandClosedState;
|
|
35345
34950
|
return quitCmd;
|
|
35346
34951
|
}
|
|
35347
|
-
static createQuery(sql, values, cb,
|
|
34952
|
+
static createQuery(sql, values, cb, config) {
|
|
35348
34953
|
let options = {
|
|
35349
|
-
rowsAsArray:
|
|
35350
|
-
infileStreamFactory:
|
|
34954
|
+
rowsAsArray: config.rowsAsArray,
|
|
34955
|
+
infileStreamFactory: config.infileStreamFactory
|
|
35351
34956
|
};
|
|
35352
34957
|
if (typeof sql === "object") {
|
|
35353
34958
|
options = {
|
|
@@ -36178,13 +35783,13 @@ var require_pool_cluster = __commonJS((exports, module) => {
|
|
|
36178
35783
|
}
|
|
36179
35784
|
|
|
36180
35785
|
class PoolCluster extends EventEmitter2 {
|
|
36181
|
-
constructor(
|
|
35786
|
+
constructor(config) {
|
|
36182
35787
|
super();
|
|
36183
|
-
|
|
36184
|
-
this._canRetry = typeof
|
|
36185
|
-
this._removeNodeErrorCount =
|
|
36186
|
-
this._restoreNodeTimeout =
|
|
36187
|
-
this._defaultSelector =
|
|
35788
|
+
config = config || {};
|
|
35789
|
+
this._canRetry = typeof config.canRetry === "undefined" ? true : config.canRetry;
|
|
35790
|
+
this._removeNodeErrorCount = config.removeNodeErrorCount || 5;
|
|
35791
|
+
this._restoreNodeTimeout = config.restoreNodeTimeout || 0;
|
|
35792
|
+
this._defaultSelector = config.defaultSelector || "RR";
|
|
36188
35793
|
this._closed = false;
|
|
36189
35794
|
this._lastId = 0;
|
|
36190
35795
|
this._nodes = {};
|
|
@@ -36205,16 +35810,16 @@ var require_pool_cluster = __commonJS((exports, module) => {
|
|
|
36205
35810
|
}
|
|
36206
35811
|
return this._namespaces[key];
|
|
36207
35812
|
}
|
|
36208
|
-
add(id,
|
|
35813
|
+
add(id, config) {
|
|
36209
35814
|
if (typeof id === "object") {
|
|
36210
|
-
|
|
35815
|
+
config = id;
|
|
36211
35816
|
id = `CLUSTER::${++this._lastId}`;
|
|
36212
35817
|
}
|
|
36213
35818
|
if (typeof this._nodes[id] === "undefined") {
|
|
36214
35819
|
this._nodes[id] = {
|
|
36215
35820
|
id,
|
|
36216
35821
|
errorCount: 0,
|
|
36217
|
-
pool: new Pool({ config: new PoolConfig(
|
|
35822
|
+
pool: new Pool({ config: new PoolConfig(config) }),
|
|
36218
35823
|
_offlineUntil: 0
|
|
36219
35824
|
};
|
|
36220
35825
|
this._serviceableNodeIds.push(id);
|
|
@@ -36364,8 +35969,8 @@ var require_create_connection = __commonJS((exports, module) => {
|
|
|
36364
35969
|
var require_create_pool = __commonJS((exports, module) => {
|
|
36365
35970
|
var Pool = require_pool3();
|
|
36366
35971
|
var PoolConfig = require_pool_config();
|
|
36367
|
-
function createPool(
|
|
36368
|
-
return new Pool({ config: new PoolConfig(
|
|
35972
|
+
function createPool(config) {
|
|
35973
|
+
return new Pool({ config: new PoolConfig(config) });
|
|
36369
35974
|
}
|
|
36370
35975
|
module.exports = createPool;
|
|
36371
35976
|
});
|
|
@@ -36373,8 +35978,8 @@ var require_create_pool = __commonJS((exports, module) => {
|
|
|
36373
35978
|
// ../../node_modules/mysql2/lib/create_pool_cluster.js
|
|
36374
35979
|
var require_create_pool_cluster = __commonJS((exports, module) => {
|
|
36375
35980
|
var PoolCluster = require_pool_cluster();
|
|
36376
|
-
function createPoolCluster(
|
|
36377
|
-
return new PoolCluster(
|
|
35981
|
+
function createPoolCluster(config) {
|
|
35982
|
+
return new PoolCluster(config);
|
|
36378
35983
|
}
|
|
36379
35984
|
module.exports = createPoolCluster;
|
|
36380
35985
|
});
|
|
@@ -36898,27 +36503,27 @@ var require_react_development = __commonJS((exports, module) => {
|
|
|
36898
36503
|
{
|
|
36899
36504
|
didWarnAboutStringRefs = {};
|
|
36900
36505
|
}
|
|
36901
|
-
function hasValidRef(
|
|
36506
|
+
function hasValidRef(config) {
|
|
36902
36507
|
{
|
|
36903
|
-
if (hasOwnProperty2.call(
|
|
36904
|
-
var getter = Object.getOwnPropertyDescriptor(
|
|
36508
|
+
if (hasOwnProperty2.call(config, "ref")) {
|
|
36509
|
+
var getter = Object.getOwnPropertyDescriptor(config, "ref").get;
|
|
36905
36510
|
if (getter && getter.isReactWarning) {
|
|
36906
36511
|
return false;
|
|
36907
36512
|
}
|
|
36908
36513
|
}
|
|
36909
36514
|
}
|
|
36910
|
-
return
|
|
36515
|
+
return config.ref !== undefined;
|
|
36911
36516
|
}
|
|
36912
|
-
function hasValidKey(
|
|
36517
|
+
function hasValidKey(config) {
|
|
36913
36518
|
{
|
|
36914
|
-
if (hasOwnProperty2.call(
|
|
36915
|
-
var getter = Object.getOwnPropertyDescriptor(
|
|
36519
|
+
if (hasOwnProperty2.call(config, "key")) {
|
|
36520
|
+
var getter = Object.getOwnPropertyDescriptor(config, "key").get;
|
|
36916
36521
|
if (getter && getter.isReactWarning) {
|
|
36917
36522
|
return false;
|
|
36918
36523
|
}
|
|
36919
36524
|
}
|
|
36920
36525
|
}
|
|
36921
|
-
return
|
|
36526
|
+
return config.key !== undefined;
|
|
36922
36527
|
}
|
|
36923
36528
|
function defineKeyPropWarningGetter(props, displayName) {
|
|
36924
36529
|
var warnAboutAccessingKey = function() {
|
|
@@ -36950,12 +36555,12 @@ var require_react_development = __commonJS((exports, module) => {
|
|
|
36950
36555
|
configurable: true
|
|
36951
36556
|
});
|
|
36952
36557
|
}
|
|
36953
|
-
function warnIfStringRefCannotBeAutoConverted(
|
|
36558
|
+
function warnIfStringRefCannotBeAutoConverted(config) {
|
|
36954
36559
|
{
|
|
36955
|
-
if (typeof
|
|
36560
|
+
if (typeof config.ref === "string" && ReactCurrentOwner.current && config.__self && ReactCurrentOwner.current.stateNode !== config.__self) {
|
|
36956
36561
|
var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);
|
|
36957
36562
|
if (!didWarnAboutStringRefs[componentName]) {
|
|
36958
|
-
error('Component "%s" contains the string ref "%s". ' + "Support for string refs will be removed in a future major release. " + "This case cannot be automatically converted to an arrow function. " + "We ask you to manually fix this case by using useRef() or createRef() instead. " + "Learn more about using refs safely here: " + "https://reactjs.org/link/strict-mode-string-ref", componentName,
|
|
36563
|
+
error('Component "%s" contains the string ref "%s". ' + "Support for string refs will be removed in a future major release. " + "This case cannot be automatically converted to an arrow function. " + "We ask you to manually fix this case by using useRef() or createRef() instead. " + "Learn more about using refs safely here: " + "https://reactjs.org/link/strict-mode-string-ref", componentName, config.ref);
|
|
36959
36564
|
didWarnAboutStringRefs[componentName] = true;
|
|
36960
36565
|
}
|
|
36961
36566
|
}
|
|
@@ -36997,31 +36602,31 @@ var require_react_development = __commonJS((exports, module) => {
|
|
|
36997
36602
|
}
|
|
36998
36603
|
return element;
|
|
36999
36604
|
};
|
|
37000
|
-
function createElement(type,
|
|
36605
|
+
function createElement(type, config, children) {
|
|
37001
36606
|
var propName;
|
|
37002
36607
|
var props = {};
|
|
37003
36608
|
var key = null;
|
|
37004
36609
|
var ref = null;
|
|
37005
36610
|
var self2 = null;
|
|
37006
36611
|
var source = null;
|
|
37007
|
-
if (
|
|
37008
|
-
if (hasValidRef(
|
|
37009
|
-
ref =
|
|
36612
|
+
if (config != null) {
|
|
36613
|
+
if (hasValidRef(config)) {
|
|
36614
|
+
ref = config.ref;
|
|
37010
36615
|
{
|
|
37011
|
-
warnIfStringRefCannotBeAutoConverted(
|
|
36616
|
+
warnIfStringRefCannotBeAutoConverted(config);
|
|
37012
36617
|
}
|
|
37013
36618
|
}
|
|
37014
|
-
if (hasValidKey(
|
|
36619
|
+
if (hasValidKey(config)) {
|
|
37015
36620
|
{
|
|
37016
|
-
checkKeyStringCoercion(
|
|
36621
|
+
checkKeyStringCoercion(config.key);
|
|
37017
36622
|
}
|
|
37018
|
-
key = "" +
|
|
36623
|
+
key = "" + config.key;
|
|
37019
36624
|
}
|
|
37020
|
-
self2 =
|
|
37021
|
-
source =
|
|
37022
|
-
for (propName in
|
|
37023
|
-
if (hasOwnProperty2.call(
|
|
37024
|
-
props[propName] =
|
|
36625
|
+
self2 = config.__self === undefined ? null : config.__self;
|
|
36626
|
+
source = config.__source === undefined ? null : config.__source;
|
|
36627
|
+
for (propName in config) {
|
|
36628
|
+
if (hasOwnProperty2.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
36629
|
+
props[propName] = config[propName];
|
|
37025
36630
|
}
|
|
37026
36631
|
}
|
|
37027
36632
|
}
|
|
@@ -37065,7 +36670,7 @@ var require_react_development = __commonJS((exports, module) => {
|
|
|
37065
36670
|
var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
|
|
37066
36671
|
return newElement;
|
|
37067
36672
|
}
|
|
37068
|
-
function cloneElement(element,
|
|
36673
|
+
function cloneElement(element, config, children) {
|
|
37069
36674
|
if (element === null || element === undefined) {
|
|
37070
36675
|
throw new Error("React.cloneElement(...): The argument must be a React element, but you passed " + element + ".");
|
|
37071
36676
|
}
|
|
@@ -37076,27 +36681,27 @@ var require_react_development = __commonJS((exports, module) => {
|
|
|
37076
36681
|
var self2 = element._self;
|
|
37077
36682
|
var source = element._source;
|
|
37078
36683
|
var owner = element._owner;
|
|
37079
|
-
if (
|
|
37080
|
-
if (hasValidRef(
|
|
37081
|
-
ref =
|
|
36684
|
+
if (config != null) {
|
|
36685
|
+
if (hasValidRef(config)) {
|
|
36686
|
+
ref = config.ref;
|
|
37082
36687
|
owner = ReactCurrentOwner.current;
|
|
37083
36688
|
}
|
|
37084
|
-
if (hasValidKey(
|
|
36689
|
+
if (hasValidKey(config)) {
|
|
37085
36690
|
{
|
|
37086
|
-
checkKeyStringCoercion(
|
|
36691
|
+
checkKeyStringCoercion(config.key);
|
|
37087
36692
|
}
|
|
37088
|
-
key = "" +
|
|
36693
|
+
key = "" + config.key;
|
|
37089
36694
|
}
|
|
37090
36695
|
var defaultProps;
|
|
37091
36696
|
if (element.type && element.type.defaultProps) {
|
|
37092
36697
|
defaultProps = element.type.defaultProps;
|
|
37093
36698
|
}
|
|
37094
|
-
for (propName in
|
|
37095
|
-
if (hasOwnProperty2.call(
|
|
37096
|
-
if (
|
|
36699
|
+
for (propName in config) {
|
|
36700
|
+
if (hasOwnProperty2.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
36701
|
+
if (config[propName] === undefined && defaultProps !== undefined) {
|
|
37097
36702
|
props[propName] = defaultProps[propName];
|
|
37098
36703
|
} else {
|
|
37099
|
-
props[propName] =
|
|
36704
|
+
props[propName] = config[propName];
|
|
37100
36705
|
}
|
|
37101
36706
|
}
|
|
37102
36707
|
}
|
|
@@ -55429,34 +55034,34 @@ var require_react_jsx_runtime_development = __commonJS((exports) => {
|
|
|
55429
55034
|
{
|
|
55430
55035
|
didWarnAboutStringRefs = {};
|
|
55431
55036
|
}
|
|
55432
|
-
function hasValidRef(
|
|
55037
|
+
function hasValidRef(config) {
|
|
55433
55038
|
{
|
|
55434
|
-
if (hasOwnProperty4.call(
|
|
55435
|
-
var getter = Object.getOwnPropertyDescriptor(
|
|
55039
|
+
if (hasOwnProperty4.call(config, "ref")) {
|
|
55040
|
+
var getter = Object.getOwnPropertyDescriptor(config, "ref").get;
|
|
55436
55041
|
if (getter && getter.isReactWarning) {
|
|
55437
55042
|
return false;
|
|
55438
55043
|
}
|
|
55439
55044
|
}
|
|
55440
55045
|
}
|
|
55441
|
-
return
|
|
55046
|
+
return config.ref !== undefined;
|
|
55442
55047
|
}
|
|
55443
|
-
function hasValidKey(
|
|
55048
|
+
function hasValidKey(config) {
|
|
55444
55049
|
{
|
|
55445
|
-
if (hasOwnProperty4.call(
|
|
55446
|
-
var getter = Object.getOwnPropertyDescriptor(
|
|
55050
|
+
if (hasOwnProperty4.call(config, "key")) {
|
|
55051
|
+
var getter = Object.getOwnPropertyDescriptor(config, "key").get;
|
|
55447
55052
|
if (getter && getter.isReactWarning) {
|
|
55448
55053
|
return false;
|
|
55449
55054
|
}
|
|
55450
55055
|
}
|
|
55451
55056
|
}
|
|
55452
|
-
return
|
|
55057
|
+
return config.key !== undefined;
|
|
55453
55058
|
}
|
|
55454
|
-
function warnIfStringRefCannotBeAutoConverted(
|
|
55059
|
+
function warnIfStringRefCannotBeAutoConverted(config, self2) {
|
|
55455
55060
|
{
|
|
55456
|
-
if (typeof
|
|
55061
|
+
if (typeof config.ref === "string" && ReactCurrentOwner.current && self2 && ReactCurrentOwner.current.stateNode !== self2) {
|
|
55457
55062
|
var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);
|
|
55458
55063
|
if (!didWarnAboutStringRefs[componentName]) {
|
|
55459
|
-
error('Component "%s" contains the string ref "%s". ' + "Support for string refs will be removed in a future major release. " + "This case cannot be automatically converted to an arrow function. " + "We ask you to manually fix this case by using useRef() or createRef() instead. " + "Learn more about using refs safely here: " + "https://reactjs.org/link/strict-mode-string-ref", getComponentNameFromType(ReactCurrentOwner.current.type),
|
|
55064
|
+
error('Component "%s" contains the string ref "%s". ' + "Support for string refs will be removed in a future major release. " + "This case cannot be automatically converted to an arrow function. " + "We ask you to manually fix this case by using useRef() or createRef() instead. " + "Learn more about using refs safely here: " + "https://reactjs.org/link/strict-mode-string-ref", getComponentNameFromType(ReactCurrentOwner.current.type), config.ref);
|
|
55460
55065
|
didWarnAboutStringRefs[componentName] = true;
|
|
55461
55066
|
}
|
|
55462
55067
|
}
|
|
@@ -55528,7 +55133,7 @@ var require_react_jsx_runtime_development = __commonJS((exports) => {
|
|
|
55528
55133
|
}
|
|
55529
55134
|
return element2;
|
|
55530
55135
|
};
|
|
55531
|
-
function jsxDEV(type,
|
|
55136
|
+
function jsxDEV(type, config, maybeKey, source, self2) {
|
|
55532
55137
|
{
|
|
55533
55138
|
var propName;
|
|
55534
55139
|
var props = {};
|
|
@@ -55540,19 +55145,19 @@ var require_react_jsx_runtime_development = __commonJS((exports) => {
|
|
|
55540
55145
|
}
|
|
55541
55146
|
key = "" + maybeKey;
|
|
55542
55147
|
}
|
|
55543
|
-
if (hasValidKey(
|
|
55148
|
+
if (hasValidKey(config)) {
|
|
55544
55149
|
{
|
|
55545
|
-
checkKeyStringCoercion(
|
|
55150
|
+
checkKeyStringCoercion(config.key);
|
|
55546
55151
|
}
|
|
55547
|
-
key = "" +
|
|
55152
|
+
key = "" + config.key;
|
|
55548
55153
|
}
|
|
55549
|
-
if (hasValidRef(
|
|
55550
|
-
ref2 =
|
|
55551
|
-
warnIfStringRefCannotBeAutoConverted(
|
|
55154
|
+
if (hasValidRef(config)) {
|
|
55155
|
+
ref2 = config.ref;
|
|
55156
|
+
warnIfStringRefCannotBeAutoConverted(config, self2);
|
|
55552
55157
|
}
|
|
55553
|
-
for (propName in
|
|
55554
|
-
if (hasOwnProperty4.call(
|
|
55555
|
-
props[propName] =
|
|
55158
|
+
for (propName in config) {
|
|
55159
|
+
if (hasOwnProperty4.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
55160
|
+
props[propName] = config[propName];
|
|
55556
55161
|
}
|
|
55557
55162
|
}
|
|
55558
55163
|
if (type && type.defaultProps) {
|
|
@@ -55871,13 +55476,13 @@ __export(exports_system_block, {
|
|
|
55871
55476
|
WP: () => WP,
|
|
55872
55477
|
Shortcode: () => Shortcode
|
|
55873
55478
|
});
|
|
55874
|
-
function systemBlock(
|
|
55479
|
+
function systemBlock(config) {
|
|
55875
55480
|
const SystemBlockComponent = (props) => {
|
|
55876
55481
|
const { children, ...attributes } = props;
|
|
55877
|
-
const content4 =
|
|
55878
|
-
return createFSEWrapper(
|
|
55482
|
+
const content4 = config.render(props);
|
|
55483
|
+
return createFSEWrapper(config.name, attributes, content4 || children);
|
|
55879
55484
|
};
|
|
55880
|
-
SystemBlockComponent.displayName = `SystemBlock(${
|
|
55485
|
+
SystemBlockComponent.displayName = `SystemBlock(${config.name})`;
|
|
55881
55486
|
return SystemBlockComponent;
|
|
55882
55487
|
}
|
|
55883
55488
|
var import_react2, WP = ({
|
|
@@ -81290,7 +80895,6 @@ Conflict Resolution:`));
|
|
|
81290
80895
|
}
|
|
81291
80896
|
}
|
|
81292
80897
|
// src/config/config-manager.ts
|
|
81293
|
-
var dotenv = __toESM(require_main(), 1);
|
|
81294
80898
|
import * as fs2 from "fs";
|
|
81295
80899
|
import * as path2 from "path";
|
|
81296
80900
|
|
|
@@ -81304,7 +80908,32 @@ class ConfigManager {
|
|
|
81304
80908
|
this.configPath = path2.join(process.cwd(), "wordpress-flow.config.json");
|
|
81305
80909
|
this.configDir = path2.dirname(this.configPath);
|
|
81306
80910
|
this.envPath = path2.join(this.configDir, ".env");
|
|
81307
|
-
|
|
80911
|
+
this.loadEnvFile();
|
|
80912
|
+
}
|
|
80913
|
+
loadEnvFile() {
|
|
80914
|
+
if (!fs2.existsSync(this.envPath))
|
|
80915
|
+
return;
|
|
80916
|
+
try {
|
|
80917
|
+
const content2 = fs2.readFileSync(this.envPath, "utf8");
|
|
80918
|
+
const lines = content2.split(`
|
|
80919
|
+
`);
|
|
80920
|
+
for (const line of lines) {
|
|
80921
|
+
const trimmed = line.trim();
|
|
80922
|
+
if (!trimmed || trimmed.startsWith("#"))
|
|
80923
|
+
continue;
|
|
80924
|
+
const eqIndex = trimmed.indexOf("=");
|
|
80925
|
+
if (eqIndex === -1)
|
|
80926
|
+
continue;
|
|
80927
|
+
const key = trimmed.slice(0, eqIndex).trim();
|
|
80928
|
+
let value = trimmed.slice(eqIndex + 1).trim();
|
|
80929
|
+
if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
|
|
80930
|
+
value = value.slice(1, -1);
|
|
80931
|
+
}
|
|
80932
|
+
if (process.env[key] === undefined) {
|
|
80933
|
+
process.env[key] = value;
|
|
80934
|
+
}
|
|
80935
|
+
}
|
|
80936
|
+
} catch {}
|
|
81308
80937
|
}
|
|
81309
80938
|
static getInstance() {
|
|
81310
80939
|
if (!ConfigManager.instance) {
|
|
@@ -81321,19 +80950,19 @@ class ConfigManager {
|
|
|
81321
80950
|
}
|
|
81322
80951
|
try {
|
|
81323
80952
|
const configContent = fs2.readFileSync(this.configPath, "utf8");
|
|
81324
|
-
const
|
|
81325
|
-
this.config = this.mergeWithEnvCredentials(
|
|
80953
|
+
const config = JSON.parse(configContent);
|
|
80954
|
+
this.config = this.mergeWithEnvCredentials(config);
|
|
81326
80955
|
return this.config;
|
|
81327
80956
|
} catch (error) {
|
|
81328
80957
|
throw new Error(`Failed to load configuration: ${error.message}`);
|
|
81329
80958
|
}
|
|
81330
80959
|
}
|
|
81331
|
-
async saveConfig(
|
|
81332
|
-
const publicConfig = this.stripSensitiveData(
|
|
81333
|
-
const envVars = this.extractEnvVars(
|
|
80960
|
+
async saveConfig(config) {
|
|
80961
|
+
const publicConfig = this.stripSensitiveData(config);
|
|
80962
|
+
const envVars = this.extractEnvVars(config);
|
|
81334
80963
|
fs2.writeFileSync(this.configPath, JSON.stringify(publicConfig, null, 2));
|
|
81335
80964
|
await this.updateEnvFile(envVars);
|
|
81336
|
-
this.config =
|
|
80965
|
+
this.config = config;
|
|
81337
80966
|
}
|
|
81338
80967
|
getConfig() {
|
|
81339
80968
|
if (!this.config) {
|
|
@@ -81359,8 +80988,8 @@ class ConfigManager {
|
|
|
81359
80988
|
getConfigDir() {
|
|
81360
80989
|
return this.configDir;
|
|
81361
80990
|
}
|
|
81362
|
-
mergeWithEnvCredentials(
|
|
81363
|
-
const mergedConfig = { ...
|
|
80991
|
+
mergeWithEnvCredentials(config) {
|
|
80992
|
+
const mergedConfig = { ...config };
|
|
81364
80993
|
if (mergedConfig.wordpress.type === "rest-api") {
|
|
81365
80994
|
const password = process.env.WP_APPLICATION_PASSWORD;
|
|
81366
80995
|
if (password && password !== "undefined") {
|
|
@@ -81374,8 +81003,8 @@ class ConfigManager {
|
|
|
81374
81003
|
}
|
|
81375
81004
|
return mergedConfig;
|
|
81376
81005
|
}
|
|
81377
|
-
stripSensitiveData(
|
|
81378
|
-
const strippedConfig = JSON.parse(JSON.stringify(
|
|
81006
|
+
stripSensitiveData(config) {
|
|
81007
|
+
const strippedConfig = JSON.parse(JSON.stringify(config));
|
|
81379
81008
|
if (strippedConfig.wordpress.type === "rest-api") {
|
|
81380
81009
|
delete strippedConfig.wordpress.applicationPassword;
|
|
81381
81010
|
} else if (strippedConfig.wordpress.type === "database") {
|
|
@@ -81383,12 +81012,12 @@ class ConfigManager {
|
|
|
81383
81012
|
}
|
|
81384
81013
|
return strippedConfig;
|
|
81385
81014
|
}
|
|
81386
|
-
extractEnvVars(
|
|
81015
|
+
extractEnvVars(config) {
|
|
81387
81016
|
const envVars = {};
|
|
81388
|
-
if (
|
|
81389
|
-
envVars.WP_APPLICATION_PASSWORD =
|
|
81390
|
-
} else if (
|
|
81391
|
-
envVars.DB_PASSWORD =
|
|
81017
|
+
if (config.wordpress.type === "rest-api") {
|
|
81018
|
+
envVars.WP_APPLICATION_PASSWORD = config.wordpress.applicationPassword;
|
|
81019
|
+
} else if (config.wordpress.type === "database") {
|
|
81020
|
+
envVars.DB_PASSWORD = config.wordpress.database.password;
|
|
81392
81021
|
}
|
|
81393
81022
|
return envVars;
|
|
81394
81023
|
}
|
|
@@ -81865,7 +81494,7 @@ var utils_default = {
|
|
|
81865
81494
|
};
|
|
81866
81495
|
|
|
81867
81496
|
// ../../node_modules/axios/lib/core/AxiosError.js
|
|
81868
|
-
function AxiosError(message, code,
|
|
81497
|
+
function AxiosError(message, code, config, request, response) {
|
|
81869
81498
|
Error.call(this);
|
|
81870
81499
|
if (Error.captureStackTrace) {
|
|
81871
81500
|
Error.captureStackTrace(this, this.constructor);
|
|
@@ -81875,7 +81504,7 @@ function AxiosError(message, code, config2, request, response) {
|
|
|
81875
81504
|
this.message = message;
|
|
81876
81505
|
this.name = "AxiosError";
|
|
81877
81506
|
code && (this.code = code);
|
|
81878
|
-
|
|
81507
|
+
config && (this.config = config);
|
|
81879
81508
|
request && (this.request = request);
|
|
81880
81509
|
if (response) {
|
|
81881
81510
|
this.response = response;
|
|
@@ -81919,7 +81548,7 @@ var descriptors = {};
|
|
|
81919
81548
|
});
|
|
81920
81549
|
Object.defineProperties(AxiosError, descriptors);
|
|
81921
81550
|
Object.defineProperty(prototype, "isAxiosError", { value: true });
|
|
81922
|
-
AxiosError.from = (error, code,
|
|
81551
|
+
AxiosError.from = (error, code, config, request, response, customProps) => {
|
|
81923
81552
|
const axiosError = Object.create(prototype);
|
|
81924
81553
|
utils_default.toFlatObject(error, axiosError, function filter(obj) {
|
|
81925
81554
|
return obj !== Error.prototype;
|
|
@@ -81928,7 +81557,7 @@ AxiosError.from = (error, code, config2, request, response, customProps) => {
|
|
|
81928
81557
|
});
|
|
81929
81558
|
const msg = error && error.message ? error.message : "Error";
|
|
81930
81559
|
const errCode = code == null && error ? error.code : code;
|
|
81931
|
-
AxiosError.call(axiosError, msg, errCode,
|
|
81560
|
+
AxiosError.call(axiosError, msg, errCode, config, request, response);
|
|
81932
81561
|
if (error && axiosError.cause == null) {
|
|
81933
81562
|
Object.defineProperty(axiosError, "cause", { value: error, configurable: true });
|
|
81934
81563
|
}
|
|
@@ -82664,12 +82293,12 @@ var AxiosHeaders_default = AxiosHeaders;
|
|
|
82664
82293
|
|
|
82665
82294
|
// ../../node_modules/axios/lib/core/transformData.js
|
|
82666
82295
|
function transformData(fns, response) {
|
|
82667
|
-
const
|
|
82668
|
-
const context = response ||
|
|
82296
|
+
const config = this || defaults_default;
|
|
82297
|
+
const context = response || config;
|
|
82669
82298
|
const headers = AxiosHeaders_default.from(context.headers);
|
|
82670
82299
|
let data = context.data;
|
|
82671
82300
|
utils_default.forEach(fns, function transform(fn) {
|
|
82672
|
-
data = fn.call(
|
|
82301
|
+
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
|
82673
82302
|
});
|
|
82674
82303
|
headers.normalize();
|
|
82675
82304
|
return data;
|
|
@@ -82681,8 +82310,8 @@ function isCancel(value) {
|
|
|
82681
82310
|
}
|
|
82682
82311
|
|
|
82683
82312
|
// ../../node_modules/axios/lib/cancel/CanceledError.js
|
|
82684
|
-
function CanceledError(message,
|
|
82685
|
-
AxiosError_default.call(this, message == null ? "canceled" : message, AxiosError_default.ERR_CANCELED,
|
|
82313
|
+
function CanceledError(message, config, request) {
|
|
82314
|
+
AxiosError_default.call(this, message == null ? "canceled" : message, AxiosError_default.ERR_CANCELED, config, request);
|
|
82686
82315
|
this.name = "CanceledError";
|
|
82687
82316
|
}
|
|
82688
82317
|
utils_default.inherits(CanceledError, AxiosError_default, {
|
|
@@ -83379,17 +83008,17 @@ var http2Transport = {
|
|
|
83379
83008
|
return req;
|
|
83380
83009
|
}
|
|
83381
83010
|
};
|
|
83382
|
-
var http_default = isHttpAdapterSupported && function httpAdapter(
|
|
83011
|
+
var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
83383
83012
|
return wrapAsync(async function dispatchHttpRequest(resolve3, reject, onDone) {
|
|
83384
|
-
let { data, lookup, family, httpVersion = 1, http2Options } =
|
|
83385
|
-
const { responseType, responseEncoding } =
|
|
83386
|
-
const method =
|
|
83013
|
+
let { data, lookup, family, httpVersion = 1, http2Options } = config;
|
|
83014
|
+
const { responseType, responseEncoding } = config;
|
|
83015
|
+
const method = config.method.toUpperCase();
|
|
83387
83016
|
let isDone;
|
|
83388
83017
|
let rejected = false;
|
|
83389
83018
|
let req;
|
|
83390
83019
|
httpVersion = +httpVersion;
|
|
83391
83020
|
if (Number.isNaN(httpVersion)) {
|
|
83392
|
-
throw TypeError(`Invalid protocol version: '${
|
|
83021
|
+
throw TypeError(`Invalid protocol version: '${config.httpVersion}' is not a number`);
|
|
83393
83022
|
}
|
|
83394
83023
|
if (httpVersion !== 1 && httpVersion !== 2) {
|
|
83395
83024
|
throw TypeError(`Unsupported protocol version '${httpVersion}'`);
|
|
@@ -83410,25 +83039,25 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
|
83410
83039
|
const abortEmitter = new EventEmitter;
|
|
83411
83040
|
function abort(reason) {
|
|
83412
83041
|
try {
|
|
83413
|
-
abortEmitter.emit("abort", !reason || reason.type ? new CanceledError_default(null,
|
|
83042
|
+
abortEmitter.emit("abort", !reason || reason.type ? new CanceledError_default(null, config, req) : reason);
|
|
83414
83043
|
} catch (err) {
|
|
83415
83044
|
console.warn("emit error", err);
|
|
83416
83045
|
}
|
|
83417
83046
|
}
|
|
83418
83047
|
abortEmitter.once("abort", reject);
|
|
83419
83048
|
const onFinished = () => {
|
|
83420
|
-
if (
|
|
83421
|
-
|
|
83049
|
+
if (config.cancelToken) {
|
|
83050
|
+
config.cancelToken.unsubscribe(abort);
|
|
83422
83051
|
}
|
|
83423
|
-
if (
|
|
83424
|
-
|
|
83052
|
+
if (config.signal) {
|
|
83053
|
+
config.signal.removeEventListener("abort", abort);
|
|
83425
83054
|
}
|
|
83426
83055
|
abortEmitter.removeAllListeners();
|
|
83427
83056
|
};
|
|
83428
|
-
if (
|
|
83429
|
-
|
|
83430
|
-
if (
|
|
83431
|
-
|
|
83057
|
+
if (config.cancelToken || config.signal) {
|
|
83058
|
+
config.cancelToken && config.cancelToken.subscribe(abort);
|
|
83059
|
+
if (config.signal) {
|
|
83060
|
+
config.signal.aborted ? abort() : config.signal.addEventListener("abort", abort);
|
|
83432
83061
|
}
|
|
83433
83062
|
}
|
|
83434
83063
|
onDone((response, isRejected) => {
|
|
@@ -83448,15 +83077,15 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
|
83448
83077
|
onFinished();
|
|
83449
83078
|
}
|
|
83450
83079
|
});
|
|
83451
|
-
const fullPath = buildFullPath(
|
|
83080
|
+
const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
|
|
83452
83081
|
const parsed = new URL(fullPath, platform_default.hasBrowserEnv ? platform_default.origin : undefined);
|
|
83453
83082
|
const protocol = parsed.protocol || supportedProtocols[0];
|
|
83454
83083
|
if (protocol === "data:") {
|
|
83455
|
-
if (
|
|
83456
|
-
const dataUrl = String(
|
|
83084
|
+
if (config.maxContentLength > -1) {
|
|
83085
|
+
const dataUrl = String(config.url || fullPath || "");
|
|
83457
83086
|
const estimated = estimateDataURLDecodedBytes(dataUrl);
|
|
83458
|
-
if (estimated >
|
|
83459
|
-
return reject(new AxiosError_default("maxContentLength size of " +
|
|
83087
|
+
if (estimated > config.maxContentLength) {
|
|
83088
|
+
return reject(new AxiosError_default("maxContentLength size of " + config.maxContentLength + " exceeded", AxiosError_default.ERR_BAD_RESPONSE, config));
|
|
83460
83089
|
}
|
|
83461
83090
|
}
|
|
83462
83091
|
let convertedData;
|
|
@@ -83465,15 +83094,15 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
|
83465
83094
|
status: 405,
|
|
83466
83095
|
statusText: "method not allowed",
|
|
83467
83096
|
headers: {},
|
|
83468
|
-
config
|
|
83097
|
+
config
|
|
83469
83098
|
});
|
|
83470
83099
|
}
|
|
83471
83100
|
try {
|
|
83472
|
-
convertedData = fromDataURI(
|
|
83473
|
-
Blob:
|
|
83101
|
+
convertedData = fromDataURI(config.url, responseType === "blob", {
|
|
83102
|
+
Blob: config.env && config.env.Blob
|
|
83474
83103
|
});
|
|
83475
83104
|
} catch (err) {
|
|
83476
|
-
throw AxiosError_default.from(err, AxiosError_default.ERR_BAD_REQUEST,
|
|
83105
|
+
throw AxiosError_default.from(err, AxiosError_default.ERR_BAD_REQUEST, config);
|
|
83477
83106
|
}
|
|
83478
83107
|
if (responseType === "text") {
|
|
83479
83108
|
convertedData = convertedData.toString(responseEncoding);
|
|
@@ -83488,16 +83117,16 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
|
83488
83117
|
status: 200,
|
|
83489
83118
|
statusText: "OK",
|
|
83490
83119
|
headers: new AxiosHeaders_default,
|
|
83491
|
-
config
|
|
83120
|
+
config
|
|
83492
83121
|
});
|
|
83493
83122
|
}
|
|
83494
83123
|
if (supportedProtocols.indexOf(protocol) === -1) {
|
|
83495
|
-
return reject(new AxiosError_default("Unsupported protocol " + protocol, AxiosError_default.ERR_BAD_REQUEST,
|
|
83124
|
+
return reject(new AxiosError_default("Unsupported protocol " + protocol, AxiosError_default.ERR_BAD_REQUEST, config));
|
|
83496
83125
|
}
|
|
83497
|
-
const headers = AxiosHeaders_default.from(
|
|
83126
|
+
const headers = AxiosHeaders_default.from(config.headers).normalize();
|
|
83498
83127
|
headers.set("User-Agent", "axios/" + VERSION, false);
|
|
83499
|
-
const { onUploadProgress, onDownloadProgress } =
|
|
83500
|
-
const maxRate =
|
|
83128
|
+
const { onUploadProgress, onDownloadProgress } = config;
|
|
83129
|
+
const maxRate = config.maxRate;
|
|
83501
83130
|
let maxUploadRate = undefined;
|
|
83502
83131
|
let maxDownloadRate = undefined;
|
|
83503
83132
|
if (utils_default.isSpecCompliantForm(data)) {
|
|
@@ -83526,11 +83155,11 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
|
83526
83155
|
} else if (utils_default.isString(data)) {
|
|
83527
83156
|
data = Buffer.from(data, "utf-8");
|
|
83528
83157
|
} else {
|
|
83529
|
-
return reject(new AxiosError_default("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream", AxiosError_default.ERR_BAD_REQUEST,
|
|
83158
|
+
return reject(new AxiosError_default("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream", AxiosError_default.ERR_BAD_REQUEST, config));
|
|
83530
83159
|
}
|
|
83531
83160
|
headers.setContentLength(data.length, false);
|
|
83532
|
-
if (
|
|
83533
|
-
return reject(new AxiosError_default("Request body larger than maxBodyLength limit", AxiosError_default.ERR_BAD_REQUEST,
|
|
83161
|
+
if (config.maxBodyLength > -1 && data.length > config.maxBodyLength) {
|
|
83162
|
+
return reject(new AxiosError_default("Request body larger than maxBodyLength limit", AxiosError_default.ERR_BAD_REQUEST, config));
|
|
83534
83163
|
}
|
|
83535
83164
|
}
|
|
83536
83165
|
const contentLength = utils_default.toFiniteNumber(headers.getContentLength());
|
|
@@ -83550,9 +83179,9 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
|
83550
83179
|
onUploadProgress && data.on("progress", flushOnFinish(data, progressEventDecorator(contentLength, progressEventReducer(asyncDecorator(onUploadProgress), false, 3))));
|
|
83551
83180
|
}
|
|
83552
83181
|
let auth = undefined;
|
|
83553
|
-
if (
|
|
83554
|
-
const username =
|
|
83555
|
-
const password =
|
|
83182
|
+
if (config.auth) {
|
|
83183
|
+
const username = config.auth.username || "";
|
|
83184
|
+
const password = config.auth.password || "";
|
|
83556
83185
|
auth = username + ":" + password;
|
|
83557
83186
|
}
|
|
83558
83187
|
if (!auth && parsed.username) {
|
|
@@ -83563,11 +83192,11 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
|
83563
83192
|
auth && headers.delete("authorization");
|
|
83564
83193
|
let path3;
|
|
83565
83194
|
try {
|
|
83566
|
-
path3 = buildURL(parsed.pathname + parsed.search,
|
|
83195
|
+
path3 = buildURL(parsed.pathname + parsed.search, config.params, config.paramsSerializer).replace(/^\?/, "");
|
|
83567
83196
|
} catch (err) {
|
|
83568
83197
|
const customErr = new Error(err.message);
|
|
83569
|
-
customErr.config =
|
|
83570
|
-
customErr.url =
|
|
83198
|
+
customErr.config = config;
|
|
83199
|
+
customErr.url = config.url;
|
|
83571
83200
|
customErr.exists = true;
|
|
83572
83201
|
return reject(customErr);
|
|
83573
83202
|
}
|
|
@@ -83576,7 +83205,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
|
83576
83205
|
path: path3,
|
|
83577
83206
|
method,
|
|
83578
83207
|
headers: headers.toJSON(),
|
|
83579
|
-
agents: { http:
|
|
83208
|
+
agents: { http: config.httpAgent, https: config.httpsAgent },
|
|
83580
83209
|
auth,
|
|
83581
83210
|
protocol,
|
|
83582
83211
|
family,
|
|
@@ -83585,40 +83214,40 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
|
83585
83214
|
http2Options
|
|
83586
83215
|
};
|
|
83587
83216
|
!utils_default.isUndefined(lookup) && (options.lookup = lookup);
|
|
83588
|
-
if (
|
|
83589
|
-
options.socketPath =
|
|
83217
|
+
if (config.socketPath) {
|
|
83218
|
+
options.socketPath = config.socketPath;
|
|
83590
83219
|
} else {
|
|
83591
83220
|
options.hostname = parsed.hostname.startsWith("[") ? parsed.hostname.slice(1, -1) : parsed.hostname;
|
|
83592
83221
|
options.port = parsed.port;
|
|
83593
|
-
setProxy(options,
|
|
83222
|
+
setProxy(options, config.proxy, protocol + "//" + parsed.hostname + (parsed.port ? ":" + parsed.port : "") + options.path);
|
|
83594
83223
|
}
|
|
83595
83224
|
let transport;
|
|
83596
83225
|
const isHttpsRequest = isHttps.test(options.protocol);
|
|
83597
|
-
options.agent = isHttpsRequest ?
|
|
83226
|
+
options.agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
|
|
83598
83227
|
if (isHttp2) {
|
|
83599
83228
|
transport = http2Transport;
|
|
83600
83229
|
} else {
|
|
83601
|
-
if (
|
|
83602
|
-
transport =
|
|
83603
|
-
} else if (
|
|
83230
|
+
if (config.transport) {
|
|
83231
|
+
transport = config.transport;
|
|
83232
|
+
} else if (config.maxRedirects === 0) {
|
|
83604
83233
|
transport = isHttpsRequest ? https : http;
|
|
83605
83234
|
} else {
|
|
83606
|
-
if (
|
|
83607
|
-
options.maxRedirects =
|
|
83235
|
+
if (config.maxRedirects) {
|
|
83236
|
+
options.maxRedirects = config.maxRedirects;
|
|
83608
83237
|
}
|
|
83609
|
-
if (
|
|
83610
|
-
options.beforeRedirects.config =
|
|
83238
|
+
if (config.beforeRedirect) {
|
|
83239
|
+
options.beforeRedirects.config = config.beforeRedirect;
|
|
83611
83240
|
}
|
|
83612
83241
|
transport = isHttpsRequest ? httpsFollow : httpFollow;
|
|
83613
83242
|
}
|
|
83614
83243
|
}
|
|
83615
|
-
if (
|
|
83616
|
-
options.maxBodyLength =
|
|
83244
|
+
if (config.maxBodyLength > -1) {
|
|
83245
|
+
options.maxBodyLength = config.maxBodyLength;
|
|
83617
83246
|
} else {
|
|
83618
83247
|
options.maxBodyLength = Infinity;
|
|
83619
83248
|
}
|
|
83620
|
-
if (
|
|
83621
|
-
options.insecureHTTPParser =
|
|
83249
|
+
if (config.insecureHTTPParser) {
|
|
83250
|
+
options.insecureHTTPParser = config.insecureHTTPParser;
|
|
83622
83251
|
}
|
|
83623
83252
|
req = transport.request(options, function handleResponse(res) {
|
|
83624
83253
|
if (req.destroyed)
|
|
@@ -83634,7 +83263,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
|
83634
83263
|
}
|
|
83635
83264
|
let responseStream = res;
|
|
83636
83265
|
const lastRequest = res.req || req;
|
|
83637
|
-
if (
|
|
83266
|
+
if (config.decompress !== false && res.headers["content-encoding"]) {
|
|
83638
83267
|
if (method === "HEAD" || res.statusCode === 204) {
|
|
83639
83268
|
delete res.headers["content-encoding"];
|
|
83640
83269
|
}
|
|
@@ -83663,7 +83292,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
|
83663
83292
|
status: res.statusCode,
|
|
83664
83293
|
statusText: res.statusMessage,
|
|
83665
83294
|
headers: new AxiosHeaders_default(res.headers),
|
|
83666
|
-
config
|
|
83295
|
+
config,
|
|
83667
83296
|
request: lastRequest
|
|
83668
83297
|
};
|
|
83669
83298
|
if (responseType === "stream") {
|
|
@@ -83675,24 +83304,24 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
|
83675
83304
|
responseStream.on("data", function handleStreamData(chunk) {
|
|
83676
83305
|
responseBuffer.push(chunk);
|
|
83677
83306
|
totalResponseBytes += chunk.length;
|
|
83678
|
-
if (
|
|
83307
|
+
if (config.maxContentLength > -1 && totalResponseBytes > config.maxContentLength) {
|
|
83679
83308
|
rejected = true;
|
|
83680
83309
|
responseStream.destroy();
|
|
83681
|
-
abort(new AxiosError_default("maxContentLength size of " +
|
|
83310
|
+
abort(new AxiosError_default("maxContentLength size of " + config.maxContentLength + " exceeded", AxiosError_default.ERR_BAD_RESPONSE, config, lastRequest));
|
|
83682
83311
|
}
|
|
83683
83312
|
});
|
|
83684
83313
|
responseStream.on("aborted", function handlerStreamAborted() {
|
|
83685
83314
|
if (rejected) {
|
|
83686
83315
|
return;
|
|
83687
83316
|
}
|
|
83688
|
-
const err = new AxiosError_default("stream has been aborted", AxiosError_default.ERR_BAD_RESPONSE,
|
|
83317
|
+
const err = new AxiosError_default("stream has been aborted", AxiosError_default.ERR_BAD_RESPONSE, config, lastRequest);
|
|
83689
83318
|
responseStream.destroy(err);
|
|
83690
83319
|
reject(err);
|
|
83691
83320
|
});
|
|
83692
83321
|
responseStream.on("error", function handleStreamError(err) {
|
|
83693
83322
|
if (req.destroyed)
|
|
83694
83323
|
return;
|
|
83695
|
-
reject(AxiosError_default.from(err, null,
|
|
83324
|
+
reject(AxiosError_default.from(err, null, config, lastRequest));
|
|
83696
83325
|
});
|
|
83697
83326
|
responseStream.on("end", function handleStreamEnd() {
|
|
83698
83327
|
try {
|
|
@@ -83705,7 +83334,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
|
83705
83334
|
}
|
|
83706
83335
|
response.data = responseData;
|
|
83707
83336
|
} catch (err) {
|
|
83708
|
-
return reject(AxiosError_default.from(err, null,
|
|
83337
|
+
return reject(AxiosError_default.from(err, null, config, response.request, response));
|
|
83709
83338
|
}
|
|
83710
83339
|
settle(resolve3, reject, response);
|
|
83711
83340
|
});
|
|
@@ -83725,26 +83354,26 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
|
83725
83354
|
}
|
|
83726
83355
|
});
|
|
83727
83356
|
req.on("error", function handleRequestError(err) {
|
|
83728
|
-
reject(AxiosError_default.from(err, null,
|
|
83357
|
+
reject(AxiosError_default.from(err, null, config, req));
|
|
83729
83358
|
});
|
|
83730
83359
|
req.on("socket", function handleRequestSocket(socket) {
|
|
83731
83360
|
socket.setKeepAlive(true, 1000 * 60);
|
|
83732
83361
|
});
|
|
83733
|
-
if (
|
|
83734
|
-
const timeout = parseInt(
|
|
83362
|
+
if (config.timeout) {
|
|
83363
|
+
const timeout = parseInt(config.timeout, 10);
|
|
83735
83364
|
if (Number.isNaN(timeout)) {
|
|
83736
|
-
abort(new AxiosError_default("error trying to parse `config.timeout` to int", AxiosError_default.ERR_BAD_OPTION_VALUE,
|
|
83365
|
+
abort(new AxiosError_default("error trying to parse `config.timeout` to int", AxiosError_default.ERR_BAD_OPTION_VALUE, config, req));
|
|
83737
83366
|
return;
|
|
83738
83367
|
}
|
|
83739
83368
|
req.setTimeout(timeout, function handleRequestTimeout() {
|
|
83740
83369
|
if (isDone)
|
|
83741
83370
|
return;
|
|
83742
|
-
let timeoutErrorMessage =
|
|
83743
|
-
const transitional =
|
|
83744
|
-
if (
|
|
83745
|
-
timeoutErrorMessage =
|
|
83371
|
+
let timeoutErrorMessage = config.timeout ? "timeout of " + config.timeout + "ms exceeded" : "timeout exceeded";
|
|
83372
|
+
const transitional = config.transitional || transitional_default;
|
|
83373
|
+
if (config.timeoutErrorMessage) {
|
|
83374
|
+
timeoutErrorMessage = config.timeoutErrorMessage;
|
|
83746
83375
|
}
|
|
83747
|
-
abort(new AxiosError_default(timeoutErrorMessage, transitional.clarifyTimeoutError ? AxiosError_default.ETIMEDOUT : AxiosError_default.ECONNABORTED,
|
|
83376
|
+
abort(new AxiosError_default(timeoutErrorMessage, transitional.clarifyTimeoutError ? AxiosError_default.ETIMEDOUT : AxiosError_default.ECONNABORTED, config, req));
|
|
83748
83377
|
});
|
|
83749
83378
|
} else {
|
|
83750
83379
|
req.setTimeout(0);
|
|
@@ -83761,7 +83390,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
|
83761
83390
|
});
|
|
83762
83391
|
data.on("close", () => {
|
|
83763
83392
|
if (!ended && !errored) {
|
|
83764
|
-
abort(new CanceledError_default("Request stream has been aborted",
|
|
83393
|
+
abort(new CanceledError_default("Request stream has been aborted", config, req));
|
|
83765
83394
|
}
|
|
83766
83395
|
});
|
|
83767
83396
|
data.pipe(req);
|
|
@@ -83822,7 +83451,7 @@ var cookies_default = platform_default.hasStandardBrowserEnv ? {
|
|
|
83822
83451
|
var headersToObject = (thing) => thing instanceof AxiosHeaders_default ? { ...thing } : thing;
|
|
83823
83452
|
function mergeConfig(config1, config2) {
|
|
83824
83453
|
config2 = config2 || {};
|
|
83825
|
-
const
|
|
83454
|
+
const config = {};
|
|
83826
83455
|
function getMergedValue(target, source, prop, caseless) {
|
|
83827
83456
|
if (utils_default.isPlainObject(target) && utils_default.isPlainObject(source)) {
|
|
83828
83457
|
return utils_default.merge.call({ caseless }, target, source);
|
|
@@ -83893,17 +83522,17 @@ function mergeConfig(config1, config2) {
|
|
|
83893
83522
|
utils_default.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) {
|
|
83894
83523
|
const merge2 = mergeMap[prop] || mergeDeepProperties;
|
|
83895
83524
|
const configValue = merge2(config1[prop], config2[prop], prop);
|
|
83896
|
-
utils_default.isUndefined(configValue) && merge2 !== mergeDirectKeys || (
|
|
83525
|
+
utils_default.isUndefined(configValue) && merge2 !== mergeDirectKeys || (config[prop] = configValue);
|
|
83897
83526
|
});
|
|
83898
|
-
return
|
|
83527
|
+
return config;
|
|
83899
83528
|
}
|
|
83900
83529
|
|
|
83901
83530
|
// ../../node_modules/axios/lib/helpers/resolveConfig.js
|
|
83902
|
-
var resolveConfig_default = (
|
|
83903
|
-
const newConfig = mergeConfig({},
|
|
83531
|
+
var resolveConfig_default = (config) => {
|
|
83532
|
+
const newConfig = mergeConfig({}, config);
|
|
83904
83533
|
let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
|
|
83905
83534
|
newConfig.headers = headers = AxiosHeaders_default.from(headers);
|
|
83906
|
-
newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls),
|
|
83535
|
+
newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls), config.params, config.paramsSerializer);
|
|
83907
83536
|
if (auth) {
|
|
83908
83537
|
headers.set("Authorization", "Basic " + btoa((auth.username || "") + ":" + (auth.password ? unescape(encodeURIComponent(auth.password)) : "")));
|
|
83909
83538
|
}
|
|
@@ -83934,9 +83563,9 @@ var resolveConfig_default = (config2) => {
|
|
|
83934
83563
|
|
|
83935
83564
|
// ../../node_modules/axios/lib/adapters/xhr.js
|
|
83936
83565
|
var isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
|
|
83937
|
-
var xhr_default = isXHRAdapterSupported && function(
|
|
83566
|
+
var xhr_default = isXHRAdapterSupported && function(config) {
|
|
83938
83567
|
return new Promise(function dispatchXhrRequest(resolve3, reject) {
|
|
83939
|
-
const _config = resolveConfig_default(
|
|
83568
|
+
const _config = resolveConfig_default(config);
|
|
83940
83569
|
let requestData = _config.data;
|
|
83941
83570
|
const requestHeaders = AxiosHeaders_default.from(_config.headers).normalize();
|
|
83942
83571
|
let { responseType, onUploadProgress, onDownloadProgress } = _config;
|
|
@@ -83963,7 +83592,7 @@ var xhr_default = isXHRAdapterSupported && function(config2) {
|
|
|
83963
83592
|
status: request.status,
|
|
83964
83593
|
statusText: request.statusText,
|
|
83965
83594
|
headers: responseHeaders,
|
|
83966
|
-
config
|
|
83595
|
+
config,
|
|
83967
83596
|
request
|
|
83968
83597
|
};
|
|
83969
83598
|
settle(function _resolve(value) {
|
|
@@ -83992,12 +83621,12 @@ var xhr_default = isXHRAdapterSupported && function(config2) {
|
|
|
83992
83621
|
if (!request) {
|
|
83993
83622
|
return;
|
|
83994
83623
|
}
|
|
83995
|
-
reject(new AxiosError_default("Request aborted", AxiosError_default.ECONNABORTED,
|
|
83624
|
+
reject(new AxiosError_default("Request aborted", AxiosError_default.ECONNABORTED, config, request));
|
|
83996
83625
|
request = null;
|
|
83997
83626
|
};
|
|
83998
83627
|
request.onerror = function handleError(event) {
|
|
83999
83628
|
const msg = event && event.message ? event.message : "Network Error";
|
|
84000
|
-
const err = new AxiosError_default(msg, AxiosError_default.ERR_NETWORK,
|
|
83629
|
+
const err = new AxiosError_default(msg, AxiosError_default.ERR_NETWORK, config, request);
|
|
84001
83630
|
err.event = event || null;
|
|
84002
83631
|
reject(err);
|
|
84003
83632
|
request = null;
|
|
@@ -84008,7 +83637,7 @@ var xhr_default = isXHRAdapterSupported && function(config2) {
|
|
|
84008
83637
|
if (_config.timeoutErrorMessage) {
|
|
84009
83638
|
timeoutErrorMessage = _config.timeoutErrorMessage;
|
|
84010
83639
|
}
|
|
84011
|
-
reject(new AxiosError_default(timeoutErrorMessage, transitional.clarifyTimeoutError ? AxiosError_default.ETIMEDOUT : AxiosError_default.ECONNABORTED,
|
|
83640
|
+
reject(new AxiosError_default(timeoutErrorMessage, transitional.clarifyTimeoutError ? AxiosError_default.ETIMEDOUT : AxiosError_default.ECONNABORTED, config, request));
|
|
84012
83641
|
request = null;
|
|
84013
83642
|
};
|
|
84014
83643
|
requestData === undefined && requestHeaders.setContentType(null);
|
|
@@ -84037,7 +83666,7 @@ var xhr_default = isXHRAdapterSupported && function(config2) {
|
|
|
84037
83666
|
if (!request) {
|
|
84038
83667
|
return;
|
|
84039
83668
|
}
|
|
84040
|
-
reject(!cancel || cancel.type ? new CanceledError_default(null,
|
|
83669
|
+
reject(!cancel || cancel.type ? new CanceledError_default(null, config, request) : cancel);
|
|
84041
83670
|
request.abort();
|
|
84042
83671
|
request = null;
|
|
84043
83672
|
};
|
|
@@ -84048,7 +83677,7 @@ var xhr_default = isXHRAdapterSupported && function(config2) {
|
|
|
84048
83677
|
}
|
|
84049
83678
|
const protocol = parseProtocol(_config.url);
|
|
84050
83679
|
if (protocol && platform_default.protocols.indexOf(protocol) === -1) {
|
|
84051
|
-
reject(new AxiosError_default("Unsupported protocol " + protocol + ":", AxiosError_default.ERR_BAD_REQUEST,
|
|
83680
|
+
reject(new AxiosError_default("Unsupported protocol " + protocol + ":", AxiosError_default.ERR_BAD_REQUEST, config));
|
|
84052
83681
|
return;
|
|
84053
83682
|
}
|
|
84054
83683
|
request.send(requestData || null);
|
|
@@ -84217,12 +83846,12 @@ var factory = (env) => {
|
|
|
84217
83846
|
};
|
|
84218
83847
|
isFetchSupported && (() => {
|
|
84219
83848
|
["text", "arrayBuffer", "blob", "formData", "stream"].forEach((type) => {
|
|
84220
|
-
!resolvers[type] && (resolvers[type] = (res,
|
|
83849
|
+
!resolvers[type] && (resolvers[type] = (res, config) => {
|
|
84221
83850
|
let method = res && res[type];
|
|
84222
83851
|
if (method) {
|
|
84223
83852
|
return method.call(res);
|
|
84224
83853
|
}
|
|
84225
|
-
throw new AxiosError_default(`Response type '${type}' is not supported`, AxiosError_default.ERR_NOT_SUPPORT,
|
|
83854
|
+
throw new AxiosError_default(`Response type '${type}' is not supported`, AxiosError_default.ERR_NOT_SUPPORT, config);
|
|
84226
83855
|
});
|
|
84227
83856
|
});
|
|
84228
83857
|
})();
|
|
@@ -84254,7 +83883,7 @@ var factory = (env) => {
|
|
|
84254
83883
|
const length = utils_default.toFiniteNumber(headers.getContentLength());
|
|
84255
83884
|
return length == null ? getBodyLength(body) : length;
|
|
84256
83885
|
};
|
|
84257
|
-
return async (
|
|
83886
|
+
return async (config) => {
|
|
84258
83887
|
let {
|
|
84259
83888
|
url: url2,
|
|
84260
83889
|
method,
|
|
@@ -84268,7 +83897,7 @@ var factory = (env) => {
|
|
|
84268
83897
|
headers,
|
|
84269
83898
|
withCredentials = "same-origin",
|
|
84270
83899
|
fetchOptions
|
|
84271
|
-
} = resolveConfig_default(
|
|
83900
|
+
} = resolveConfig_default(config);
|
|
84272
83901
|
let _fetch = envFetch || fetch;
|
|
84273
83902
|
responseType = responseType ? (responseType + "").toLowerCase() : "text";
|
|
84274
83903
|
let composedSignal = composeSignals_default([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
|
@@ -84322,7 +83951,7 @@ var factory = (env) => {
|
|
|
84322
83951
|
}), options);
|
|
84323
83952
|
}
|
|
84324
83953
|
responseType = responseType || "text";
|
|
84325
|
-
let responseData = await resolvers[utils_default.findKey(resolvers, responseType) || "text"](response,
|
|
83954
|
+
let responseData = await resolvers[utils_default.findKey(resolvers, responseType) || "text"](response, config);
|
|
84326
83955
|
!isStreamResponse && unsubscribe && unsubscribe();
|
|
84327
83956
|
return await new Promise((resolve3, reject) => {
|
|
84328
83957
|
settle(resolve3, reject, {
|
|
@@ -84330,24 +83959,24 @@ var factory = (env) => {
|
|
|
84330
83959
|
headers: AxiosHeaders_default.from(response.headers),
|
|
84331
83960
|
status: response.status,
|
|
84332
83961
|
statusText: response.statusText,
|
|
84333
|
-
config
|
|
83962
|
+
config,
|
|
84334
83963
|
request
|
|
84335
83964
|
});
|
|
84336
83965
|
});
|
|
84337
83966
|
} catch (err) {
|
|
84338
83967
|
unsubscribe && unsubscribe();
|
|
84339
83968
|
if (err && err.name === "TypeError" && /Load failed|fetch/i.test(err.message)) {
|
|
84340
|
-
throw Object.assign(new AxiosError_default("Network Error", AxiosError_default.ERR_NETWORK,
|
|
83969
|
+
throw Object.assign(new AxiosError_default("Network Error", AxiosError_default.ERR_NETWORK, config, request), {
|
|
84341
83970
|
cause: err.cause || err
|
|
84342
83971
|
});
|
|
84343
83972
|
}
|
|
84344
|
-
throw AxiosError_default.from(err, err && err.code,
|
|
83973
|
+
throw AxiosError_default.from(err, err && err.code, config, request);
|
|
84345
83974
|
}
|
|
84346
83975
|
};
|
|
84347
83976
|
};
|
|
84348
83977
|
var seedCache = new Map;
|
|
84349
|
-
var getFetch = (
|
|
84350
|
-
let env =
|
|
83978
|
+
var getFetch = (config) => {
|
|
83979
|
+
let env = config && config.env || {};
|
|
84351
83980
|
const { fetch: fetch2, Request, Response } = env;
|
|
84352
83981
|
const seeds = [
|
|
84353
83982
|
Request,
|
|
@@ -84383,7 +84012,7 @@ utils_default.forEach(knownAdapters, (fn, value) => {
|
|
|
84383
84012
|
});
|
|
84384
84013
|
var renderReason = (reason) => `- ${reason}`;
|
|
84385
84014
|
var isResolvedHandle = (adapter2) => utils_default.isFunction(adapter2) || adapter2 === null || adapter2 === false;
|
|
84386
|
-
function getAdapter(adapters,
|
|
84015
|
+
function getAdapter(adapters, config) {
|
|
84387
84016
|
adapters = utils_default.isArray(adapters) ? adapters : [adapters];
|
|
84388
84017
|
const { length } = adapters;
|
|
84389
84018
|
let nameOrAdapter;
|
|
@@ -84399,7 +84028,7 @@ function getAdapter(adapters, config2) {
|
|
|
84399
84028
|
throw new AxiosError_default(`Unknown adapter '${id}'`);
|
|
84400
84029
|
}
|
|
84401
84030
|
}
|
|
84402
|
-
if (adapter2 && (utils_default.isFunction(adapter2) || (adapter2 = adapter2.get(
|
|
84031
|
+
if (adapter2 && (utils_default.isFunction(adapter2) || (adapter2 = adapter2.get(config)))) {
|
|
84403
84032
|
break;
|
|
84404
84033
|
}
|
|
84405
84034
|
rejectedReasons[id || "#" + i] = adapter2;
|
|
@@ -84419,32 +84048,32 @@ var adapters_default = {
|
|
|
84419
84048
|
};
|
|
84420
84049
|
|
|
84421
84050
|
// ../../node_modules/axios/lib/core/dispatchRequest.js
|
|
84422
|
-
function throwIfCancellationRequested(
|
|
84423
|
-
if (
|
|
84424
|
-
|
|
84051
|
+
function throwIfCancellationRequested(config) {
|
|
84052
|
+
if (config.cancelToken) {
|
|
84053
|
+
config.cancelToken.throwIfRequested();
|
|
84425
84054
|
}
|
|
84426
|
-
if (
|
|
84427
|
-
throw new CanceledError_default(null,
|
|
84055
|
+
if (config.signal && config.signal.aborted) {
|
|
84056
|
+
throw new CanceledError_default(null, config);
|
|
84428
84057
|
}
|
|
84429
84058
|
}
|
|
84430
|
-
function dispatchRequest(
|
|
84431
|
-
throwIfCancellationRequested(
|
|
84432
|
-
|
|
84433
|
-
|
|
84434
|
-
if (["post", "put", "patch"].indexOf(
|
|
84435
|
-
|
|
84059
|
+
function dispatchRequest(config) {
|
|
84060
|
+
throwIfCancellationRequested(config);
|
|
84061
|
+
config.headers = AxiosHeaders_default.from(config.headers);
|
|
84062
|
+
config.data = transformData.call(config, config.transformRequest);
|
|
84063
|
+
if (["post", "put", "patch"].indexOf(config.method) !== -1) {
|
|
84064
|
+
config.headers.setContentType("application/x-www-form-urlencoded", false);
|
|
84436
84065
|
}
|
|
84437
|
-
const adapter2 = adapters_default.getAdapter(
|
|
84438
|
-
return adapter2(
|
|
84439
|
-
throwIfCancellationRequested(
|
|
84440
|
-
response.data = transformData.call(
|
|
84066
|
+
const adapter2 = adapters_default.getAdapter(config.adapter || defaults_default.adapter, config);
|
|
84067
|
+
return adapter2(config).then(function onAdapterResolution(response) {
|
|
84068
|
+
throwIfCancellationRequested(config);
|
|
84069
|
+
response.data = transformData.call(config, config.transformResponse, response);
|
|
84441
84070
|
response.headers = AxiosHeaders_default.from(response.headers);
|
|
84442
84071
|
return response;
|
|
84443
84072
|
}, function onAdapterRejection(reason) {
|
|
84444
84073
|
if (!isCancel(reason)) {
|
|
84445
|
-
throwIfCancellationRequested(
|
|
84074
|
+
throwIfCancellationRequested(config);
|
|
84446
84075
|
if (reason && reason.response) {
|
|
84447
|
-
reason.response.data = transformData.call(
|
|
84076
|
+
reason.response.data = transformData.call(config, config.transformResponse, reason.response);
|
|
84448
84077
|
reason.response.headers = AxiosHeaders_default.from(reason.response.headers);
|
|
84449
84078
|
}
|
|
84450
84079
|
}
|
|
@@ -84519,9 +84148,9 @@ class Axios {
|
|
|
84519
84148
|
response: new InterceptorManager_default
|
|
84520
84149
|
};
|
|
84521
84150
|
}
|
|
84522
|
-
async request(configOrUrl,
|
|
84151
|
+
async request(configOrUrl, config) {
|
|
84523
84152
|
try {
|
|
84524
|
-
return await this._request(configOrUrl,
|
|
84153
|
+
return await this._request(configOrUrl, config);
|
|
84525
84154
|
} catch (err) {
|
|
84526
84155
|
if (err instanceof Error) {
|
|
84527
84156
|
let dummy = {};
|
|
@@ -84539,15 +84168,15 @@ class Axios {
|
|
|
84539
84168
|
throw err;
|
|
84540
84169
|
}
|
|
84541
84170
|
}
|
|
84542
|
-
_request(configOrUrl,
|
|
84171
|
+
_request(configOrUrl, config) {
|
|
84543
84172
|
if (typeof configOrUrl === "string") {
|
|
84544
|
-
|
|
84545
|
-
|
|
84173
|
+
config = config || {};
|
|
84174
|
+
config.url = configOrUrl;
|
|
84546
84175
|
} else {
|
|
84547
|
-
|
|
84176
|
+
config = configOrUrl || {};
|
|
84548
84177
|
}
|
|
84549
|
-
|
|
84550
|
-
const { transitional: transitional2, paramsSerializer, headers } =
|
|
84178
|
+
config = mergeConfig(this.defaults, config);
|
|
84179
|
+
const { transitional: transitional2, paramsSerializer, headers } = config;
|
|
84551
84180
|
if (transitional2 !== undefined) {
|
|
84552
84181
|
validator_default.assertOptions(transitional2, {
|
|
84553
84182
|
silentJSONParsing: validators2.transitional(validators2.boolean),
|
|
@@ -84557,7 +84186,7 @@ class Axios {
|
|
|
84557
84186
|
}
|
|
84558
84187
|
if (paramsSerializer != null) {
|
|
84559
84188
|
if (utils_default.isFunction(paramsSerializer)) {
|
|
84560
|
-
|
|
84189
|
+
config.paramsSerializer = {
|
|
84561
84190
|
serialize: paramsSerializer
|
|
84562
84191
|
};
|
|
84563
84192
|
} else {
|
|
@@ -84567,25 +84196,25 @@ class Axios {
|
|
|
84567
84196
|
}, true);
|
|
84568
84197
|
}
|
|
84569
84198
|
}
|
|
84570
|
-
if (
|
|
84571
|
-
|
|
84199
|
+
if (config.allowAbsoluteUrls !== undefined) {} else if (this.defaults.allowAbsoluteUrls !== undefined) {
|
|
84200
|
+
config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
|
|
84572
84201
|
} else {
|
|
84573
|
-
|
|
84202
|
+
config.allowAbsoluteUrls = true;
|
|
84574
84203
|
}
|
|
84575
|
-
validator_default.assertOptions(
|
|
84204
|
+
validator_default.assertOptions(config, {
|
|
84576
84205
|
baseUrl: validators2.spelling("baseURL"),
|
|
84577
84206
|
withXsrfToken: validators2.spelling("withXSRFToken")
|
|
84578
84207
|
}, true);
|
|
84579
|
-
|
|
84580
|
-
let contextHeaders = headers && utils_default.merge(headers.common, headers[
|
|
84208
|
+
config.method = (config.method || this.defaults.method || "get").toLowerCase();
|
|
84209
|
+
let contextHeaders = headers && utils_default.merge(headers.common, headers[config.method]);
|
|
84581
84210
|
headers && utils_default.forEach(["delete", "get", "head", "post", "put", "patch", "common"], (method) => {
|
|
84582
84211
|
delete headers[method];
|
|
84583
84212
|
});
|
|
84584
|
-
|
|
84213
|
+
config.headers = AxiosHeaders_default.concat(contextHeaders, headers);
|
|
84585
84214
|
const requestInterceptorChain = [];
|
|
84586
84215
|
let synchronousRequestInterceptors = true;
|
|
84587
84216
|
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
|
84588
|
-
if (typeof interceptor.runWhen === "function" && interceptor.runWhen(
|
|
84217
|
+
if (typeof interceptor.runWhen === "function" && interceptor.runWhen(config) === false) {
|
|
84589
84218
|
return;
|
|
84590
84219
|
}
|
|
84591
84220
|
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
|
@@ -84603,14 +84232,14 @@ class Axios {
|
|
|
84603
84232
|
chain.unshift(...requestInterceptorChain);
|
|
84604
84233
|
chain.push(...responseInterceptorChain);
|
|
84605
84234
|
len = chain.length;
|
|
84606
|
-
promise = Promise.resolve(
|
|
84235
|
+
promise = Promise.resolve(config);
|
|
84607
84236
|
while (i < len) {
|
|
84608
84237
|
promise = promise.then(chain[i++], chain[i++]);
|
|
84609
84238
|
}
|
|
84610
84239
|
return promise;
|
|
84611
84240
|
}
|
|
84612
84241
|
len = requestInterceptorChain.length;
|
|
84613
|
-
let newConfig =
|
|
84242
|
+
let newConfig = config;
|
|
84614
84243
|
while (i < len) {
|
|
84615
84244
|
const onFulfilled = requestInterceptorChain[i++];
|
|
84616
84245
|
const onRejected = requestInterceptorChain[i++];
|
|
@@ -84633,25 +84262,25 @@ class Axios {
|
|
|
84633
84262
|
}
|
|
84634
84263
|
return promise;
|
|
84635
84264
|
}
|
|
84636
|
-
getUri(
|
|
84637
|
-
|
|
84638
|
-
const fullPath = buildFullPath(
|
|
84639
|
-
return buildURL(fullPath,
|
|
84265
|
+
getUri(config) {
|
|
84266
|
+
config = mergeConfig(this.defaults, config);
|
|
84267
|
+
const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
|
|
84268
|
+
return buildURL(fullPath, config.params, config.paramsSerializer);
|
|
84640
84269
|
}
|
|
84641
84270
|
}
|
|
84642
84271
|
utils_default.forEach(["delete", "get", "head", "options"], function forEachMethodNoData(method) {
|
|
84643
|
-
Axios.prototype[method] = function(url2,
|
|
84644
|
-
return this.request(mergeConfig(
|
|
84272
|
+
Axios.prototype[method] = function(url2, config) {
|
|
84273
|
+
return this.request(mergeConfig(config || {}, {
|
|
84645
84274
|
method,
|
|
84646
84275
|
url: url2,
|
|
84647
|
-
data: (
|
|
84276
|
+
data: (config || {}).data
|
|
84648
84277
|
}));
|
|
84649
84278
|
};
|
|
84650
84279
|
});
|
|
84651
84280
|
utils_default.forEach(["post", "put", "patch"], function forEachMethodWithData(method) {
|
|
84652
84281
|
function generateHTTPMethod(isForm) {
|
|
84653
|
-
return function httpMethod(url2, data,
|
|
84654
|
-
return this.request(mergeConfig(
|
|
84282
|
+
return function httpMethod(url2, data, config) {
|
|
84283
|
+
return this.request(mergeConfig(config || {}, {
|
|
84655
84284
|
method,
|
|
84656
84285
|
headers: isForm ? {
|
|
84657
84286
|
"Content-Type": "multipart/form-data"
|
|
@@ -84697,11 +84326,11 @@ class CancelToken {
|
|
|
84697
84326
|
};
|
|
84698
84327
|
return promise;
|
|
84699
84328
|
};
|
|
84700
|
-
executor(function cancel(message,
|
|
84329
|
+
executor(function cancel(message, config, request) {
|
|
84701
84330
|
if (token.reason) {
|
|
84702
84331
|
return;
|
|
84703
84332
|
}
|
|
84704
|
-
token.reason = new CanceledError_default(message,
|
|
84333
|
+
token.reason = new CanceledError_default(message, config, request);
|
|
84705
84334
|
resolvePromise(token.reason);
|
|
84706
84335
|
});
|
|
84707
84336
|
}
|
|
@@ -84878,20 +84507,20 @@ var axios_default = axios;
|
|
|
84878
84507
|
class RestApiClient {
|
|
84879
84508
|
client;
|
|
84880
84509
|
config;
|
|
84881
|
-
constructor(
|
|
84882
|
-
this.config =
|
|
84883
|
-
const auth = Buffer.from(`${
|
|
84510
|
+
constructor(config) {
|
|
84511
|
+
this.config = config;
|
|
84512
|
+
const auth = Buffer.from(`${config.username}:${config.applicationPassword}`).toString("base64");
|
|
84884
84513
|
this.client = axios_default.create({
|
|
84885
|
-
baseURL: `${
|
|
84514
|
+
baseURL: `${config.wordpressUrl}/wp-json/wp/v2`,
|
|
84886
84515
|
headers: {
|
|
84887
84516
|
Authorization: `Basic ${auth}`,
|
|
84888
84517
|
"Content-Type": "application/json"
|
|
84889
84518
|
},
|
|
84890
84519
|
timeout: 30000
|
|
84891
84520
|
});
|
|
84892
|
-
this.client.interceptors.request.use((
|
|
84893
|
-
logger.debug(`Making request: ${
|
|
84894
|
-
return
|
|
84521
|
+
this.client.interceptors.request.use((config2) => {
|
|
84522
|
+
logger.debug(`Making request: ${config2.method?.toUpperCase()} ${config2.url}`);
|
|
84523
|
+
return config2;
|
|
84895
84524
|
}, (error) => {
|
|
84896
84525
|
logger.error("Request error:", error);
|
|
84897
84526
|
return Promise.reject(error);
|
|
@@ -85049,8 +84678,8 @@ var mysql = __toESM(require_promise(), 1);
|
|
|
85049
84678
|
class DatabaseClient {
|
|
85050
84679
|
connection = null;
|
|
85051
84680
|
config;
|
|
85052
|
-
constructor(
|
|
85053
|
-
this.config =
|
|
84681
|
+
constructor(config) {
|
|
84682
|
+
this.config = config;
|
|
85054
84683
|
}
|
|
85055
84684
|
async connect() {
|
|
85056
84685
|
if (this.connection) {
|
|
@@ -85464,6 +85093,7 @@ class DatabaseClient {
|
|
|
85464
85093
|
class ConnectionManager {
|
|
85465
85094
|
static instance;
|
|
85466
85095
|
connection = null;
|
|
85096
|
+
currentConfig = null;
|
|
85467
85097
|
constructor() {}
|
|
85468
85098
|
static getInstance() {
|
|
85469
85099
|
if (!ConnectionManager.instance) {
|
|
@@ -85471,20 +85101,44 @@ class ConnectionManager {
|
|
|
85471
85101
|
}
|
|
85472
85102
|
return ConnectionManager.instance;
|
|
85473
85103
|
}
|
|
85474
|
-
|
|
85475
|
-
|
|
85476
|
-
|
|
85477
|
-
|
|
85478
|
-
|
|
85104
|
+
hasConnection() {
|
|
85105
|
+
return this.connection !== null;
|
|
85106
|
+
}
|
|
85107
|
+
async createConnection(config) {
|
|
85108
|
+
if (this.connection && this.currentConfig) {
|
|
85109
|
+
const configMatches = this.configsMatch(this.currentConfig, config);
|
|
85110
|
+
if (configMatches) {
|
|
85111
|
+
return this.connection;
|
|
85112
|
+
}
|
|
85113
|
+
await this.closeConnection();
|
|
85114
|
+
}
|
|
85115
|
+
if (config.type === "rest-api") {
|
|
85116
|
+
this.connection = new RestApiClient(config);
|
|
85117
|
+
} else if (config.type === "database") {
|
|
85118
|
+
this.connection = new DatabaseClient(config);
|
|
85479
85119
|
} else {
|
|
85480
|
-
throw new Error(`Unsupported connection type: ${
|
|
85120
|
+
throw new Error(`Unsupported connection type: ${config.type}`);
|
|
85481
85121
|
}
|
|
85482
85122
|
const isConnected = await this.connection.testConnection();
|
|
85483
85123
|
if (!isConnected) {
|
|
85484
85124
|
throw new Error("Failed to establish connection to WordPress");
|
|
85485
85125
|
}
|
|
85126
|
+
this.currentConfig = config;
|
|
85486
85127
|
return this.connection;
|
|
85487
85128
|
}
|
|
85129
|
+
configsMatch(a, b) {
|
|
85130
|
+
if (a.type !== b.type)
|
|
85131
|
+
return false;
|
|
85132
|
+
if (a.wordpressUrl !== b.wordpressUrl)
|
|
85133
|
+
return false;
|
|
85134
|
+
if (a.type === "database" && b.type === "database") {
|
|
85135
|
+
return a.database.host === b.database.host && a.database.port === b.database.port && a.database.database === b.database.database && a.database.username === b.database.username;
|
|
85136
|
+
}
|
|
85137
|
+
if (a.type === "rest-api" && b.type === "rest-api") {
|
|
85138
|
+
return a.username === b.username;
|
|
85139
|
+
}
|
|
85140
|
+
return true;
|
|
85141
|
+
}
|
|
85488
85142
|
getConnection() {
|
|
85489
85143
|
if (!this.connection) {
|
|
85490
85144
|
throw new Error("No connection established. Call createConnection() first.");
|
|
@@ -85496,6 +85150,7 @@ class ConnectionManager {
|
|
|
85496
85150
|
await this.connection.close();
|
|
85497
85151
|
}
|
|
85498
85152
|
this.connection = null;
|
|
85153
|
+
this.currentConfig = null;
|
|
85499
85154
|
}
|
|
85500
85155
|
}
|
|
85501
85156
|
// ../../node_modules/@wordpress/block-serialization-default-parser/build-module/index.js
|
|
@@ -85980,8 +85635,8 @@ class PullCommand {
|
|
|
85980
85635
|
}
|
|
85981
85636
|
async execute(options) {
|
|
85982
85637
|
logger.progress("Starting pull operation...");
|
|
85983
|
-
const
|
|
85984
|
-
const connection = await this.connectionManager.createConnection(
|
|
85638
|
+
const config = this.configManager.getConfig();
|
|
85639
|
+
const connection = await this.connectionManager.createConnection(config.wordpress);
|
|
85985
85640
|
const result2 = {
|
|
85986
85641
|
success: false,
|
|
85987
85642
|
operation: {
|
|
@@ -85993,7 +85648,7 @@ class PullCommand {
|
|
|
85993
85648
|
},
|
|
85994
85649
|
target: {
|
|
85995
85650
|
type: "local",
|
|
85996
|
-
identifier: options.outputDir ||
|
|
85651
|
+
identifier: options.outputDir || config.paths.mdxOutputDir,
|
|
85997
85652
|
lastModified: new Date
|
|
85998
85653
|
},
|
|
85999
85654
|
timestamp: new Date,
|
|
@@ -86003,8 +85658,8 @@ class PullCommand {
|
|
|
86003
85658
|
errors: []
|
|
86004
85659
|
};
|
|
86005
85660
|
try {
|
|
86006
|
-
const postTypes = options.postTypes ||
|
|
86007
|
-
const outputDir = options.outputDir ||
|
|
85661
|
+
const postTypes = options.postTypes || config.wordpress.postTypes || ["post", "page"];
|
|
85662
|
+
const outputDir = options.outputDir || config.paths.mdxOutputDir;
|
|
86008
85663
|
fs3.mkdirSync(outputDir, { recursive: true });
|
|
86009
85664
|
let totalProcessed = 0;
|
|
86010
85665
|
for (const postType of postTypes) {
|
|
@@ -92118,8 +91773,8 @@ function walk(ast, { enter, leave }) {
|
|
|
92118
91773
|
// ../../node_modules/estree-util-build-jsx/lib/index.js
|
|
92119
91774
|
var regex = /@(jsx|jsxFrag|jsxImportSource|jsxRuntime)\s+(\S+)/g;
|
|
92120
91775
|
function buildJsx(tree, options) {
|
|
92121
|
-
const
|
|
92122
|
-
let automatic =
|
|
91776
|
+
const config = options || {};
|
|
91777
|
+
let automatic = config.runtime === "automatic";
|
|
92123
91778
|
const annotations = {};
|
|
92124
91779
|
const imports = {};
|
|
92125
91780
|
walk(tree, {
|
|
@@ -92201,7 +91856,7 @@ function buildJsx(tree, options) {
|
|
|
92201
91856
|
specifiers,
|
|
92202
91857
|
source: {
|
|
92203
91858
|
type: "Literal",
|
|
92204
|
-
value: (annotations.jsxImportSource ||
|
|
91859
|
+
value: (annotations.jsxImportSource || config.importSource || "react") + (config.development ? "/jsx-dev-runtime" : "/jsx-runtime")
|
|
92205
91860
|
}
|
|
92206
91861
|
});
|
|
92207
91862
|
}
|
|
@@ -92272,7 +91927,7 @@ function buildJsx(tree, options) {
|
|
|
92272
91927
|
imports.fragment = true;
|
|
92273
91928
|
name2 = { type: "Identifier", name: "_Fragment" };
|
|
92274
91929
|
} else {
|
|
92275
|
-
name2 = toMemberExpression(annotations.jsxFrag ||
|
|
91930
|
+
name2 = toMemberExpression(annotations.jsxFrag || config.pragmaFrag || "React.Fragment");
|
|
92276
91931
|
}
|
|
92277
91932
|
if (automatic) {
|
|
92278
91933
|
if (children.length > 0) {
|
|
@@ -92294,11 +91949,11 @@ function buildJsx(tree, options) {
|
|
|
92294
91949
|
parameters.push({ type: "ObjectExpression", properties: fields });
|
|
92295
91950
|
if (key) {
|
|
92296
91951
|
parameters.push(key);
|
|
92297
|
-
} else if (
|
|
91952
|
+
} else if (config.development) {
|
|
92298
91953
|
parameters.push({ type: "Identifier", name: "undefined" });
|
|
92299
91954
|
}
|
|
92300
91955
|
const isStaticChildren = children.length > 1;
|
|
92301
|
-
if (
|
|
91956
|
+
if (config.development) {
|
|
92302
91957
|
imports.jsxDEV = true;
|
|
92303
91958
|
callee = {
|
|
92304
91959
|
type: "Identifier",
|
|
@@ -92317,7 +91972,7 @@ function buildJsx(tree, options) {
|
|
|
92317
91972
|
key: { type: "Identifier", name: "fileName" },
|
|
92318
91973
|
value: {
|
|
92319
91974
|
type: "Literal",
|
|
92320
|
-
value:
|
|
91975
|
+
value: config.filePath || "<source.js>"
|
|
92321
91976
|
}
|
|
92322
91977
|
}
|
|
92323
91978
|
]
|
|
@@ -92355,7 +92010,7 @@ function buildJsx(tree, options) {
|
|
|
92355
92010
|
} else if (parameters.length > 0) {
|
|
92356
92011
|
parameters.unshift({ type: "Literal", value: null });
|
|
92357
92012
|
}
|
|
92358
|
-
callee = toMemberExpression(annotations.jsx ||
|
|
92013
|
+
callee = toMemberExpression(annotations.jsx || config.pragma || "React.createElement");
|
|
92359
92014
|
}
|
|
92360
92015
|
parameters.unshift(name2);
|
|
92361
92016
|
const call = {
|
|
@@ -109224,7 +108879,7 @@ function fromMarkdown(value, encoding, options) {
|
|
|
109224
108879
|
return compiler(options)(postprocess(parse4(options).document().write(preprocess()(value, encoding, true))));
|
|
109225
108880
|
}
|
|
109226
108881
|
function compiler(options) {
|
|
109227
|
-
const
|
|
108882
|
+
const config = {
|
|
109228
108883
|
transforms: [],
|
|
109229
108884
|
canContainEols: ["emphasis", "fragment", "heading", "paragraph", "strong"],
|
|
109230
108885
|
enter: {
|
|
@@ -109322,7 +108977,7 @@ function compiler(options) {
|
|
|
109322
108977
|
thematicBreak: closer()
|
|
109323
108978
|
}
|
|
109324
108979
|
};
|
|
109325
|
-
configure(
|
|
108980
|
+
configure(config, (options || {}).mdastExtensions || []);
|
|
109326
108981
|
const data2 = {};
|
|
109327
108982
|
return compile;
|
|
109328
108983
|
function compile(events) {
|
|
@@ -109330,7 +108985,7 @@ function compiler(options) {
|
|
|
109330
108985
|
const context = {
|
|
109331
108986
|
stack: [tree],
|
|
109332
108987
|
tokenStack: [],
|
|
109333
|
-
config
|
|
108988
|
+
config,
|
|
109334
108989
|
enter,
|
|
109335
108990
|
exit: exit2,
|
|
109336
108991
|
buffer,
|
|
@@ -109352,7 +109007,7 @@ function compiler(options) {
|
|
|
109352
109007
|
}
|
|
109353
109008
|
index2 = -1;
|
|
109354
109009
|
while (++index2 < events.length) {
|
|
109355
|
-
const handler =
|
|
109010
|
+
const handler = config[events[index2][0]];
|
|
109356
109011
|
if (own7.call(handler, events[index2][1].type)) {
|
|
109357
109012
|
handler[events[index2][1].type].call(Object.assign({ sliceSerialize: events[index2][2].sliceSerialize }, context), events[index2][1]);
|
|
109358
109013
|
}
|
|
@@ -109367,8 +109022,8 @@ function compiler(options) {
|
|
|
109367
109022
|
end: point3(events.length > 0 ? events[events.length - 2][1].end : { line: 1, column: 1, offset: 0 })
|
|
109368
109023
|
};
|
|
109369
109024
|
index2 = -1;
|
|
109370
|
-
while (++index2 <
|
|
109371
|
-
tree =
|
|
109025
|
+
while (++index2 < config.transforms.length) {
|
|
109026
|
+
tree = config.transforms[index2](tree) || tree;
|
|
109372
109027
|
}
|
|
109373
109028
|
return tree;
|
|
109374
109029
|
}
|
|
@@ -109639,7 +109294,7 @@ function compiler(options) {
|
|
|
109639
109294
|
this.data.atHardBreak = undefined;
|
|
109640
109295
|
return;
|
|
109641
109296
|
}
|
|
109642
|
-
if (!this.data.setextHeadingSlurpLineEnding &&
|
|
109297
|
+
if (!this.data.setextHeadingSlurpLineEnding && config.canContainEols.includes(context.type)) {
|
|
109643
109298
|
onenterdata.call(this, token);
|
|
109644
109299
|
onexitdata.call(this, token);
|
|
109645
109300
|
}
|
|
@@ -113251,8 +112906,8 @@ class PushCommand {
|
|
|
113251
112906
|
if (blockRegistry) {
|
|
113252
112907
|
this.blockRegistry = blockRegistry;
|
|
113253
112908
|
} else {
|
|
113254
|
-
const
|
|
113255
|
-
const buildOutputDir = this.configManager.resolvePath(
|
|
112909
|
+
const config = this.configManager.getConfig();
|
|
112910
|
+
const buildOutputDir = this.configManager.resolvePath(config.build?.outputDir || "./theme/dist");
|
|
113256
112911
|
this.blockRegistry = new BlockRegistry(buildOutputDir);
|
|
113257
112912
|
}
|
|
113258
112913
|
}
|
|
@@ -113329,8 +112984,8 @@ class PushCommand {
|
|
|
113329
112984
|
logger.warn(`Failed to load built blocks: ${error.message}`);
|
|
113330
112985
|
logger.warn("Continuing with basic block rendering...");
|
|
113331
112986
|
}
|
|
113332
|
-
const
|
|
113333
|
-
const connection = await this.connectionManager.createConnection(
|
|
112987
|
+
const config = this.configManager.getConfig();
|
|
112988
|
+
const connection = await this.connectionManager.createConnection(config.wordpress);
|
|
113334
112989
|
const result2 = {
|
|
113335
112990
|
success: false,
|
|
113336
112991
|
operation: {
|
|
@@ -113342,7 +112997,7 @@ class PushCommand {
|
|
|
113342
112997
|
},
|
|
113343
112998
|
target: {
|
|
113344
112999
|
type: "wordpress",
|
|
113345
|
-
identifier:
|
|
113000
|
+
identifier: config.wordpress.wordpressUrl,
|
|
113346
113001
|
lastModified: new Date
|
|
113347
113002
|
},
|
|
113348
113003
|
timestamp: new Date,
|
|
@@ -113353,7 +113008,7 @@ class PushCommand {
|
|
|
113353
113008
|
conflicts: []
|
|
113354
113009
|
};
|
|
113355
113010
|
try {
|
|
113356
|
-
const mdxFiles = await this.findMDXFiles(options.files,
|
|
113011
|
+
const mdxFiles = await this.findMDXFiles(options.files, config.paths.mdxOutputDir);
|
|
113357
113012
|
if (mdxFiles.length === 0) {
|
|
113358
113013
|
logger.warn("No MDX files found to push");
|
|
113359
113014
|
result2.operation.status = "completed";
|
|
@@ -113383,7 +113038,7 @@ class PushCommand {
|
|
|
113383
113038
|
logger.warn(`Found ${result2.conflicts.length} file(s) with conflicts (WordPress version is newer)`);
|
|
113384
113039
|
logger.info(`Use --force to override, or pull latest changes first`);
|
|
113385
113040
|
logger.debug(`Conflict details:`);
|
|
113386
|
-
await this.handleConflicts(result2.conflicts,
|
|
113041
|
+
await this.handleConflicts(result2.conflicts, config.sync.conflictResolution);
|
|
113387
113042
|
}
|
|
113388
113043
|
result2.operation.status = "completed";
|
|
113389
113044
|
result2.success = result2.errors.length === 0 || result2.errors.every((e) => e.recoverable);
|
|
@@ -113411,8 +113066,13 @@ class PushCommand {
|
|
|
113411
113066
|
try {
|
|
113412
113067
|
await this.blockRegistry.loadBuiltBlocks();
|
|
113413
113068
|
} catch {}
|
|
113414
|
-
const
|
|
113415
|
-
|
|
113069
|
+
const config = this.configManager.getConfig();
|
|
113070
|
+
let connection;
|
|
113071
|
+
if (this.connectionManager.hasConnection()) {
|
|
113072
|
+
connection = this.connectionManager.getConnection();
|
|
113073
|
+
} else {
|
|
113074
|
+
connection = await this.connectionManager.createConnection(config.wordpress);
|
|
113075
|
+
}
|
|
113416
113076
|
const result2 = {
|
|
113417
113077
|
success: false,
|
|
113418
113078
|
operation: {
|
|
@@ -113424,7 +113084,7 @@ class PushCommand {
|
|
|
113424
113084
|
},
|
|
113425
113085
|
target: {
|
|
113426
113086
|
type: "wordpress",
|
|
113427
|
-
identifier:
|
|
113087
|
+
identifier: config.wordpress.wordpressUrl,
|
|
113428
113088
|
lastModified: new Date
|
|
113429
113089
|
},
|
|
113430
113090
|
timestamp: new Date,
|
|
@@ -113435,7 +113095,7 @@ class PushCommand {
|
|
|
113435
113095
|
conflicts: []
|
|
113436
113096
|
};
|
|
113437
113097
|
try {
|
|
113438
|
-
const mdxFiles = await this.findMDXFiles(options.files,
|
|
113098
|
+
const mdxFiles = await this.findMDXFiles(options.files, config.paths.mdxOutputDir);
|
|
113439
113099
|
if (mdxFiles.length === 0) {
|
|
113440
113100
|
result2.operation.status = "completed";
|
|
113441
113101
|
result2.success = true;
|
|
@@ -113463,8 +113123,6 @@ class PushCommand {
|
|
|
113463
113123
|
recoverable: false
|
|
113464
113124
|
});
|
|
113465
113125
|
throw error;
|
|
113466
|
-
} finally {
|
|
113467
|
-
await this.connectionManager.closeConnection();
|
|
113468
113126
|
}
|
|
113469
113127
|
return result2;
|
|
113470
113128
|
}
|
|
@@ -113701,6 +113359,15 @@ class ChangeQueue extends EventEmitter3 {
|
|
|
113701
113359
|
});
|
|
113702
113360
|
this.scheduleFlush();
|
|
113703
113361
|
}
|
|
113362
|
+
queueTemplatePartChange(partPath, eventType) {
|
|
113363
|
+
const key = `templatePart:${partPath}`;
|
|
113364
|
+
this.pendingChanges.set(key, {
|
|
113365
|
+
type: "templatePart",
|
|
113366
|
+
filePath: partPath,
|
|
113367
|
+
eventType
|
|
113368
|
+
});
|
|
113369
|
+
this.scheduleFlush();
|
|
113370
|
+
}
|
|
113704
113371
|
queuePageChange(pagePath, eventType) {
|
|
113705
113372
|
const key = `page:${pagePath}`;
|
|
113706
113373
|
this.pendingChanges.set(key, {
|
|
@@ -113733,6 +113400,7 @@ class ChangeQueue extends EventEmitter3 {
|
|
|
113733
113400
|
buildBatch() {
|
|
113734
113401
|
const blocks = new Map;
|
|
113735
113402
|
const templates = [];
|
|
113403
|
+
const templateParts = [];
|
|
113736
113404
|
const pages = [];
|
|
113737
113405
|
const deletedBlocks = [];
|
|
113738
113406
|
for (const change of this.pendingChanges.values()) {
|
|
@@ -113758,6 +113426,11 @@ class ChangeQueue extends EventEmitter3 {
|
|
|
113758
113426
|
templates.push(change.filePath);
|
|
113759
113427
|
}
|
|
113760
113428
|
break;
|
|
113429
|
+
case "templatePart":
|
|
113430
|
+
if (change.eventType !== "unlink") {
|
|
113431
|
+
templateParts.push(change.filePath);
|
|
113432
|
+
}
|
|
113433
|
+
break;
|
|
113761
113434
|
case "page":
|
|
113762
113435
|
if (change.eventType !== "unlink") {
|
|
113763
113436
|
pages.push(change.filePath);
|
|
@@ -113768,6 +113441,7 @@ class ChangeQueue extends EventEmitter3 {
|
|
|
113768
113441
|
return {
|
|
113769
113442
|
blocks,
|
|
113770
113443
|
templates,
|
|
113444
|
+
templateParts,
|
|
113771
113445
|
pages,
|
|
113772
113446
|
deletedBlocks,
|
|
113773
113447
|
triggeredAt: Date.now()
|
|
@@ -114120,10 +113794,16 @@ class DevModeUI {
|
|
|
114120
113794
|
}
|
|
114121
113795
|
}
|
|
114122
113796
|
showWatching() {
|
|
114123
|
-
console.log(
|
|
114124
|
-
|
|
114125
|
-
|
|
114126
|
-
console.log("");
|
|
113797
|
+
console.log(`
|
|
113798
|
+
` + "─".repeat(50));
|
|
113799
|
+
console.log("✅ Dev mode ready! Watching for changes...");
|
|
113800
|
+
console.log("─".repeat(50));
|
|
113801
|
+
console.log(" • Edit blocks → auto-rebuild + cascade updates");
|
|
113802
|
+
console.log(" • Edit templates → auto-rebuild HTML");
|
|
113803
|
+
console.log(" • Edit pages → auto-push to WordPress");
|
|
113804
|
+
console.log(" • Press Ctrl+C to stop");
|
|
113805
|
+
console.log("─".repeat(50) + `
|
|
113806
|
+
`);
|
|
114127
113807
|
}
|
|
114128
113808
|
showInitialBuildStart(blockCount, cached) {
|
|
114129
113809
|
if (cached > 0) {
|
|
@@ -114866,8 +114546,8 @@ var watch = (paths, options) => {
|
|
|
114866
114546
|
var $watch = watch;
|
|
114867
114547
|
|
|
114868
114548
|
// src/dev/dev-mode-orchestrator.ts
|
|
114869
|
-
import * as
|
|
114870
|
-
import * as
|
|
114549
|
+
import * as path17 from "path";
|
|
114550
|
+
import * as fs15 from "fs";
|
|
114871
114551
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
114872
114552
|
|
|
114873
114553
|
// src/build/block-scanner.ts
|
|
@@ -115427,40 +115107,49 @@ import * as fs10 from "fs";
|
|
|
115427
115107
|
import * as path12 from "path";
|
|
115428
115108
|
class DependencyTracker {
|
|
115429
115109
|
blockToTemplates = new Map;
|
|
115110
|
+
blockToTemplateParts = new Map;
|
|
115430
115111
|
blockToPages = new Map;
|
|
115431
115112
|
fileToBlocks = new Map;
|
|
115432
115113
|
blockLocalImports = new Map;
|
|
115433
|
-
async scanDependencies(templatesDir, contentDir) {
|
|
115114
|
+
async scanDependencies(templatesDir, contentDir, templatePartsDir) {
|
|
115434
115115
|
this.blockToTemplates.clear();
|
|
115116
|
+
this.blockToTemplateParts.clear();
|
|
115435
115117
|
this.blockToPages.clear();
|
|
115436
115118
|
this.fileToBlocks.clear();
|
|
115437
115119
|
if (templatesDir && fs10.existsSync(templatesDir)) {
|
|
115438
|
-
await this.
|
|
115120
|
+
await this.scanDirectory(templatesDir, "template");
|
|
115121
|
+
}
|
|
115122
|
+
if (templatePartsDir && fs10.existsSync(templatePartsDir)) {
|
|
115123
|
+
await this.scanDirectory(templatePartsDir, "templatePart");
|
|
115439
115124
|
}
|
|
115440
115125
|
if (fs10.existsSync(contentDir)) {
|
|
115441
115126
|
await this.scanPages(contentDir);
|
|
115442
115127
|
}
|
|
115443
115128
|
const stats = this.getStats();
|
|
115444
|
-
logger.debug(`Dependency scan complete: ${stats.totalTemplates} templates, ${stats.totalPages} pages, ${stats.totalBlocks} unique blocks`);
|
|
115129
|
+
logger.debug(`Dependency scan complete: ${stats.totalTemplates} templates, ${stats.totalTemplateParts} parts, ${stats.totalPages} pages, ${stats.totalBlocks} unique blocks`);
|
|
115445
115130
|
}
|
|
115446
|
-
async
|
|
115447
|
-
const pattern = path12.join(
|
|
115131
|
+
async scanDirectory(dir, type) {
|
|
115132
|
+
const pattern = path12.join(dir, "**/*.mdx");
|
|
115448
115133
|
const files = await glob(pattern);
|
|
115134
|
+
const blockMap = type === "template" ? this.blockToTemplates : this.blockToTemplateParts;
|
|
115449
115135
|
for (const filePath2 of files) {
|
|
115450
115136
|
try {
|
|
115451
115137
|
const blocks = await this.extractBlocksFromFile(filePath2);
|
|
115452
115138
|
this.fileToBlocks.set(filePath2, new Set(blocks));
|
|
115453
115139
|
for (const blockName of blocks) {
|
|
115454
|
-
if (!
|
|
115455
|
-
|
|
115140
|
+
if (!blockMap.has(blockName)) {
|
|
115141
|
+
blockMap.set(blockName, new Set);
|
|
115456
115142
|
}
|
|
115457
|
-
|
|
115143
|
+
blockMap.get(blockName).add(filePath2);
|
|
115458
115144
|
}
|
|
115459
115145
|
} catch (error) {
|
|
115460
|
-
logger.warn(`Failed to scan
|
|
115146
|
+
logger.warn(`Failed to scan ${type} ${filePath2}: ${error}`);
|
|
115461
115147
|
}
|
|
115462
115148
|
}
|
|
115463
|
-
logger.debug(`Scanned ${files.length}
|
|
115149
|
+
logger.debug(`Scanned ${files.length} ${type}s`);
|
|
115150
|
+
}
|
|
115151
|
+
async scanTemplates(templatesDir) {
|
|
115152
|
+
await this.scanDirectory(templatesDir, "template");
|
|
115464
115153
|
}
|
|
115465
115154
|
async scanPages(contentDir) {
|
|
115466
115155
|
const patterns = [
|
|
@@ -115547,12 +115236,16 @@ class DependencyTracker {
|
|
|
115547
115236
|
getDependentTemplates(blockName) {
|
|
115548
115237
|
return Array.from(this.blockToTemplates.get(blockName) || []);
|
|
115549
115238
|
}
|
|
115239
|
+
getDependentTemplateParts(blockName) {
|
|
115240
|
+
return Array.from(this.blockToTemplateParts.get(blockName) || []);
|
|
115241
|
+
}
|
|
115550
115242
|
getDependentPages(blockName) {
|
|
115551
115243
|
return Array.from(this.blockToPages.get(blockName) || []);
|
|
115552
115244
|
}
|
|
115553
115245
|
getDependentFiles(blockName) {
|
|
115554
115246
|
return [
|
|
115555
115247
|
...this.getDependentTemplates(blockName),
|
|
115248
|
+
...this.getDependentTemplateParts(blockName),
|
|
115556
115249
|
...this.getDependentPages(blockName)
|
|
115557
115250
|
];
|
|
115558
115251
|
}
|
|
@@ -115560,16 +115253,21 @@ class DependencyTracker {
|
|
|
115560
115253
|
return Array.from(this.blockLocalImports.get(blockFilePath) || []);
|
|
115561
115254
|
}
|
|
115562
115255
|
hasDependents(blockNames) {
|
|
115563
|
-
return blockNames.some((name2) => (this.blockToTemplates.get(name2)?.size || 0) > 0 || (this.blockToPages.get(name2)?.size || 0) > 0);
|
|
115256
|
+
return blockNames.some((name2) => (this.blockToTemplates.get(name2)?.size || 0) > 0 || (this.blockToTemplateParts.get(name2)?.size || 0) > 0 || (this.blockToPages.get(name2)?.size || 0) > 0);
|
|
115564
115257
|
}
|
|
115565
115258
|
getCascade(changedBlocks) {
|
|
115566
115259
|
const templates = new Set;
|
|
115260
|
+
const templateParts = new Set;
|
|
115567
115261
|
const pages = new Set;
|
|
115568
115262
|
for (const blockName of changedBlocks) {
|
|
115569
115263
|
const blockTemplates = this.blockToTemplates.get(blockName);
|
|
115570
115264
|
if (blockTemplates) {
|
|
115571
115265
|
blockTemplates.forEach((t) => templates.add(t));
|
|
115572
115266
|
}
|
|
115267
|
+
const blockParts = this.blockToTemplateParts.get(blockName);
|
|
115268
|
+
if (blockParts) {
|
|
115269
|
+
blockParts.forEach((p) => templateParts.add(p));
|
|
115270
|
+
}
|
|
115573
115271
|
const blockPages = this.blockToPages.get(blockName);
|
|
115574
115272
|
if (blockPages) {
|
|
115575
115273
|
blockPages.forEach((p) => pages.add(p));
|
|
@@ -115577,9 +115275,64 @@ class DependencyTracker {
|
|
|
115577
115275
|
}
|
|
115578
115276
|
return {
|
|
115579
115277
|
templates: Array.from(templates),
|
|
115278
|
+
templateParts: Array.from(templateParts),
|
|
115580
115279
|
pages: Array.from(pages)
|
|
115581
115280
|
};
|
|
115582
115281
|
}
|
|
115282
|
+
getCascadeForTypes(changedBlocks, types4) {
|
|
115283
|
+
const result2 = {};
|
|
115284
|
+
for (const type of types4) {
|
|
115285
|
+
result2[type] = [];
|
|
115286
|
+
}
|
|
115287
|
+
for (const blockName of changedBlocks) {
|
|
115288
|
+
if (types4.includes("template")) {
|
|
115289
|
+
const blockTemplates = this.blockToTemplates.get(blockName);
|
|
115290
|
+
if (blockTemplates) {
|
|
115291
|
+
result2.template = [
|
|
115292
|
+
...new Set([
|
|
115293
|
+
...result2.template || [],
|
|
115294
|
+
...Array.from(blockTemplates)
|
|
115295
|
+
])
|
|
115296
|
+
];
|
|
115297
|
+
}
|
|
115298
|
+
}
|
|
115299
|
+
if (types4.includes("templatePart")) {
|
|
115300
|
+
const blockParts = this.blockToTemplateParts.get(blockName);
|
|
115301
|
+
if (blockParts) {
|
|
115302
|
+
result2.templatePart = [
|
|
115303
|
+
...new Set([
|
|
115304
|
+
...result2.templatePart || [],
|
|
115305
|
+
...Array.from(blockParts)
|
|
115306
|
+
])
|
|
115307
|
+
];
|
|
115308
|
+
}
|
|
115309
|
+
}
|
|
115310
|
+
if (types4.includes("page")) {
|
|
115311
|
+
const blockPages = this.blockToPages.get(blockName);
|
|
115312
|
+
if (blockPages) {
|
|
115313
|
+
result2.page = [
|
|
115314
|
+
...new Set([...result2.page || [], ...Array.from(blockPages)])
|
|
115315
|
+
];
|
|
115316
|
+
}
|
|
115317
|
+
}
|
|
115318
|
+
}
|
|
115319
|
+
return result2;
|
|
115320
|
+
}
|
|
115321
|
+
getAffectedArtifactTypes(changedBlocks) {
|
|
115322
|
+
const types4 = [];
|
|
115323
|
+
for (const blockName of changedBlocks) {
|
|
115324
|
+
if (!types4.includes("template") && (this.blockToTemplates.get(blockName)?.size || 0) > 0) {
|
|
115325
|
+
types4.push("template");
|
|
115326
|
+
}
|
|
115327
|
+
if (!types4.includes("templatePart") && (this.blockToTemplateParts.get(blockName)?.size || 0) > 0) {
|
|
115328
|
+
types4.push("templatePart");
|
|
115329
|
+
}
|
|
115330
|
+
if (!types4.includes("page") && (this.blockToPages.get(blockName)?.size || 0) > 0) {
|
|
115331
|
+
types4.push("page");
|
|
115332
|
+
}
|
|
115333
|
+
}
|
|
115334
|
+
return types4;
|
|
115335
|
+
}
|
|
115583
115336
|
findBlockForImport(importPath) {
|
|
115584
115337
|
for (const [blockPath, imports] of this.blockLocalImports) {
|
|
115585
115338
|
if (imports.has(importPath)) {
|
|
@@ -115594,6 +115347,8 @@ class DependencyTracker {
|
|
|
115594
115347
|
for (const blockName of oldBlocks) {
|
|
115595
115348
|
if (type === "template") {
|
|
115596
115349
|
this.blockToTemplates.get(blockName)?.delete(filePath2);
|
|
115350
|
+
} else if (type === "templatePart") {
|
|
115351
|
+
this.blockToTemplateParts.get(blockName)?.delete(filePath2);
|
|
115597
115352
|
} else {
|
|
115598
115353
|
this.blockToPages.get(blockName)?.delete(filePath2);
|
|
115599
115354
|
}
|
|
@@ -115608,6 +115363,11 @@ class DependencyTracker {
|
|
|
115608
115363
|
this.blockToTemplates.set(blockName, new Set);
|
|
115609
115364
|
}
|
|
115610
115365
|
this.blockToTemplates.get(blockName).add(filePath2);
|
|
115366
|
+
} else if (type === "templatePart") {
|
|
115367
|
+
if (!this.blockToTemplateParts.has(blockName)) {
|
|
115368
|
+
this.blockToTemplateParts.set(blockName, new Set);
|
|
115369
|
+
}
|
|
115370
|
+
this.blockToTemplateParts.get(blockName).add(filePath2);
|
|
115611
115371
|
} else {
|
|
115612
115372
|
if (!this.blockToPages.has(blockName)) {
|
|
115613
115373
|
this.blockToPages.set(blockName, new Set);
|
|
@@ -115624,6 +115384,7 @@ class DependencyTracker {
|
|
|
115624
115384
|
if (blocks) {
|
|
115625
115385
|
for (const blockName of blocks) {
|
|
115626
115386
|
this.blockToTemplates.get(blockName)?.delete(filePath2);
|
|
115387
|
+
this.blockToTemplateParts.get(blockName)?.delete(filePath2);
|
|
115627
115388
|
this.blockToPages.get(blockName)?.delete(filePath2);
|
|
115628
115389
|
}
|
|
115629
115390
|
}
|
|
@@ -115637,23 +115398,33 @@ class DependencyTracker {
|
|
|
115637
115398
|
if (templates.size > 0)
|
|
115638
115399
|
blocksWithDependents++;
|
|
115639
115400
|
}
|
|
115401
|
+
for (const [blockName, parts] of this.blockToTemplateParts) {
|
|
115402
|
+
allBlocks.add(blockName);
|
|
115403
|
+
if (parts.size > 0 && !this.blockToTemplates.get(blockName)?.size) {
|
|
115404
|
+
blocksWithDependents++;
|
|
115405
|
+
}
|
|
115406
|
+
}
|
|
115640
115407
|
for (const [blockName, pages] of this.blockToPages) {
|
|
115641
115408
|
allBlocks.add(blockName);
|
|
115642
|
-
if (pages.size > 0 && !this.blockToTemplates.get(blockName)?.size) {
|
|
115409
|
+
if (pages.size > 0 && !this.blockToTemplates.get(blockName)?.size && !this.blockToTemplateParts.get(blockName)?.size) {
|
|
115643
115410
|
blocksWithDependents++;
|
|
115644
115411
|
}
|
|
115645
115412
|
}
|
|
115646
115413
|
let totalTemplates = 0;
|
|
115414
|
+
let totalTemplateParts = 0;
|
|
115647
115415
|
let totalPages = 0;
|
|
115648
115416
|
for (const filePath2 of this.fileToBlocks.keys()) {
|
|
115649
115417
|
if (filePath2.includes("/templates/") || filePath2.includes("\\templates\\")) {
|
|
115650
115418
|
totalTemplates++;
|
|
115419
|
+
} else if (filePath2.includes("/parts/") || filePath2.includes("\\parts\\")) {
|
|
115420
|
+
totalTemplateParts++;
|
|
115651
115421
|
} else {
|
|
115652
115422
|
totalPages++;
|
|
115653
115423
|
}
|
|
115654
115424
|
}
|
|
115655
115425
|
return {
|
|
115656
115426
|
totalTemplates,
|
|
115427
|
+
totalTemplateParts,
|
|
115657
115428
|
totalPages,
|
|
115658
115429
|
totalBlocks: allBlocks.size,
|
|
115659
115430
|
blocksWithDependents
|
|
@@ -115668,6 +115439,14 @@ class DependencyTracker {
|
|
|
115668
115439
|
}
|
|
115669
115440
|
}
|
|
115670
115441
|
logger.info(`
|
|
115442
|
+
=== Block → Template Parts ===`);
|
|
115443
|
+
for (const [blockName, parts] of this.blockToTemplateParts) {
|
|
115444
|
+
if (parts.size > 0) {
|
|
115445
|
+
const names = Array.from(parts).map((p) => path12.basename(p));
|
|
115446
|
+
logger.info(`${blockName}: [${names.join(", ")}]`);
|
|
115447
|
+
}
|
|
115448
|
+
}
|
|
115449
|
+
logger.info(`
|
|
115671
115450
|
=== Block → Pages ===`);
|
|
115672
115451
|
for (const [blockName, pages] of this.blockToPages) {
|
|
115673
115452
|
if (pages.size > 0) {
|
|
@@ -115679,6 +115458,7 @@ class DependencyTracker {
|
|
|
115679
115458
|
logger.info(`
|
|
115680
115459
|
=== Stats ===`);
|
|
115681
115460
|
logger.info(`Templates: ${stats.totalTemplates}`);
|
|
115461
|
+
logger.info(`Template Parts: ${stats.totalTemplateParts}`);
|
|
115682
115462
|
logger.info(`Pages: ${stats.totalPages}`);
|
|
115683
115463
|
logger.info(`Unique blocks: ${stats.totalBlocks}`);
|
|
115684
115464
|
logger.info(`Blocks with dependents: ${stats.blocksWithDependents}`);
|
|
@@ -116006,10 +115786,380 @@ add_action('enqueue_block_assets', 'wordpress_flow_enqueue_block_scripts');
|
|
|
116006
115786
|
);`;
|
|
116007
115787
|
}
|
|
116008
115788
|
}
|
|
115789
|
+
|
|
115790
|
+
// src/env/docker-env-manager.ts
|
|
115791
|
+
import { execSync } from "child_process";
|
|
115792
|
+
import * as fs14 from "fs";
|
|
115793
|
+
import * as path16 from "path";
|
|
115794
|
+
class DockerEnvManager {
|
|
115795
|
+
projectName;
|
|
115796
|
+
workspaceDir;
|
|
115797
|
+
config;
|
|
115798
|
+
containerNames;
|
|
115799
|
+
constructor(options) {
|
|
115800
|
+
this.projectName = this.sanitizeProjectName(options.projectName);
|
|
115801
|
+
this.workspaceDir = options.workspaceDir;
|
|
115802
|
+
this.config = {
|
|
115803
|
+
port: options.config.port ?? 8888,
|
|
115804
|
+
databasePort: options.config.databasePort,
|
|
115805
|
+
phpVersion: options.config.phpVersion ?? "8.2",
|
|
115806
|
+
wordpressVersion: options.config.wordpressVersion ?? "latest",
|
|
115807
|
+
themeDir: options.config.themeDir ?? "./theme",
|
|
115808
|
+
pluginsDir: options.config.pluginsDir,
|
|
115809
|
+
plugins: options.config.plugins ?? [],
|
|
115810
|
+
sqlDump: options.config.sqlDump ?? "",
|
|
115811
|
+
volumes: {
|
|
115812
|
+
database: options.config.volumes?.database ?? true,
|
|
115813
|
+
uploads: options.config.volumes?.uploads ?? true
|
|
115814
|
+
}
|
|
115815
|
+
};
|
|
115816
|
+
this.containerNames = {
|
|
115817
|
+
wordpress: `${this.projectName}-wordpress`,
|
|
115818
|
+
mysql: `${this.projectName}-mysql`
|
|
115819
|
+
};
|
|
115820
|
+
}
|
|
115821
|
+
sanitizeProjectName(name2) {
|
|
115822
|
+
return name2.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
115823
|
+
}
|
|
115824
|
+
async checkDocker() {
|
|
115825
|
+
try {
|
|
115826
|
+
execSync("docker info", { stdio: "pipe" });
|
|
115827
|
+
return true;
|
|
115828
|
+
} catch {
|
|
115829
|
+
return false;
|
|
115830
|
+
}
|
|
115831
|
+
}
|
|
115832
|
+
async getContainerStatus() {
|
|
115833
|
+
const status = {
|
|
115834
|
+
wordpress: "not-found",
|
|
115835
|
+
mysql: "not-found"
|
|
115836
|
+
};
|
|
115837
|
+
try {
|
|
115838
|
+
const wpStatus = execSync(`docker inspect -f '{{.State.Status}}' ${this.containerNames.wordpress} 2>/dev/null`, { encoding: "utf8" }).trim();
|
|
115839
|
+
status.wordpress = wpStatus === "running" ? "running" : "stopped";
|
|
115840
|
+
} catch {
|
|
115841
|
+
status.wordpress = "not-found";
|
|
115842
|
+
}
|
|
115843
|
+
try {
|
|
115844
|
+
const mysqlStatus = execSync(`docker inspect -f '{{.State.Status}}' ${this.containerNames.mysql} 2>/dev/null`, { encoding: "utf8" }).trim();
|
|
115845
|
+
status.mysql = mysqlStatus === "running" ? "running" : "stopped";
|
|
115846
|
+
} catch {
|
|
115847
|
+
status.mysql = "not-found";
|
|
115848
|
+
}
|
|
115849
|
+
return status;
|
|
115850
|
+
}
|
|
115851
|
+
async start() {
|
|
115852
|
+
const dockerInstalled = await this.checkDocker();
|
|
115853
|
+
if (!dockerInstalled) {
|
|
115854
|
+
throw new Error(`Docker is not installed or not running.
|
|
115855
|
+
|
|
115856
|
+
` + `To install Docker:
|
|
115857
|
+
` + ` • macOS: Download from https://docker.com/products/docker-desktop
|
|
115858
|
+
` + " • Linux: Run `curl -fsSL https://get.docker.com | sh`\n" + ` • Windows: Download from https://docker.com/products/docker-desktop
|
|
115859
|
+
|
|
115860
|
+
` + "After installing, make sure Docker Desktop is running.");
|
|
115861
|
+
}
|
|
115862
|
+
const status = await this.getContainerStatus();
|
|
115863
|
+
let isFirstRun = false;
|
|
115864
|
+
if (status.wordpress === "not-found" || status.mysql === "not-found") {
|
|
115865
|
+
logger.info("\uD83D\uDC33 Creating Docker containers...");
|
|
115866
|
+
await this.createContainers();
|
|
115867
|
+
isFirstRun = true;
|
|
115868
|
+
} else if (status.wordpress === "stopped" || status.mysql === "stopped") {
|
|
115869
|
+
logger.info("\uD83D\uDC33 Starting existing containers...");
|
|
115870
|
+
await this.startContainers();
|
|
115871
|
+
} else {
|
|
115872
|
+
logger.info("\uD83D\uDC33 Docker containers already running");
|
|
115873
|
+
}
|
|
115874
|
+
await this.waitForWordPress();
|
|
115875
|
+
const wordpressUrl = `http://localhost:${this.config.port}`;
|
|
115876
|
+
return { wordpressUrl, isFirstRun };
|
|
115877
|
+
}
|
|
115878
|
+
async createContainers() {
|
|
115879
|
+
try {
|
|
115880
|
+
execSync(`docker network create ${this.projectName}-network 2>/dev/null`, {
|
|
115881
|
+
stdio: "pipe"
|
|
115882
|
+
});
|
|
115883
|
+
} catch {}
|
|
115884
|
+
const themeDir = path16.resolve(this.workspaceDir, this.config.themeDir);
|
|
115885
|
+
const themeName = path16.basename(themeDir);
|
|
115886
|
+
logger.info(" Starting MySQL...");
|
|
115887
|
+
const mysqlVolume = this.config.volumes.database ? `-v ${this.projectName}-mysql-data:/var/lib/mysql` : "";
|
|
115888
|
+
const mysqlPort = this.config.databasePort ? `-p ${this.config.databasePort}:3306` : "";
|
|
115889
|
+
execSync(`docker run -d --name ${this.containerNames.mysql} --network ${this.projectName}-network ${mysqlVolume} ${mysqlPort} -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=wordpress -e MYSQL_USER=wordpress -e MYSQL_PASSWORD=wordpress mysql:8.0`, { stdio: "pipe" });
|
|
115890
|
+
await this.waitForMySQL();
|
|
115891
|
+
logger.info(" Starting WordPress...");
|
|
115892
|
+
const uploadsVolume = this.config.volumes.uploads ? `-v ${this.projectName}-uploads:/var/www/html/wp-content/uploads` : "";
|
|
115893
|
+
let pluginMounts = "";
|
|
115894
|
+
if (this.config.pluginsDir) {
|
|
115895
|
+
const pluginsDir = path16.resolve(this.workspaceDir, this.config.pluginsDir);
|
|
115896
|
+
if (fs14.existsSync(pluginsDir)) {
|
|
115897
|
+
const pluginFolders = fs14.readdirSync(pluginsDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
|
|
115898
|
+
for (const pluginName of pluginFolders) {
|
|
115899
|
+
const pluginPath = path16.join(pluginsDir, pluginName);
|
|
115900
|
+
pluginMounts += ` -v "${pluginPath}:/var/www/html/wp-content/plugins/${pluginName}"`;
|
|
115901
|
+
}
|
|
115902
|
+
if (pluginFolders.length > 0) {
|
|
115903
|
+
logger.info(` Mounting ${pluginFolders.length} local plugin(s): ${pluginFolders.join(", ")}`);
|
|
115904
|
+
}
|
|
115905
|
+
}
|
|
115906
|
+
}
|
|
115907
|
+
const wpImage = this.config.wordpressVersion === "latest" ? `wordpress:php${this.config.phpVersion}` : `wordpress:${this.config.wordpressVersion}-php${this.config.phpVersion}`;
|
|
115908
|
+
execSync(`docker run -d --name ${this.containerNames.wordpress} --network ${this.projectName}-network -p ${this.config.port}:80 -v "${themeDir}:/var/www/html/wp-content/themes/${themeName}" ${pluginMounts} ${uploadsVolume} -e WORDPRESS_DB_HOST=${this.containerNames.mysql} -e WORDPRESS_DB_USER=wordpress -e WORDPRESS_DB_PASSWORD=wordpress -e WORDPRESS_DB_NAME=wordpress ${wpImage}`, { stdio: "pipe" });
|
|
115909
|
+
}
|
|
115910
|
+
async startContainers() {
|
|
115911
|
+
execSync(`docker start ${this.containerNames.mysql}`, { stdio: "pipe" });
|
|
115912
|
+
await this.waitForMySQL();
|
|
115913
|
+
execSync(`docker start ${this.containerNames.wordpress}`, {
|
|
115914
|
+
stdio: "pipe"
|
|
115915
|
+
});
|
|
115916
|
+
}
|
|
115917
|
+
async stop() {
|
|
115918
|
+
logger.info("\uD83D\uDC33 Stopping Docker containers...");
|
|
115919
|
+
try {
|
|
115920
|
+
execSync(`docker stop ${this.containerNames.wordpress}`, {
|
|
115921
|
+
stdio: "pipe"
|
|
115922
|
+
});
|
|
115923
|
+
} catch {}
|
|
115924
|
+
try {
|
|
115925
|
+
execSync(`docker stop ${this.containerNames.mysql}`, { stdio: "pipe" });
|
|
115926
|
+
} catch {}
|
|
115927
|
+
}
|
|
115928
|
+
async waitForMySQL() {
|
|
115929
|
+
const maxAttempts = 30;
|
|
115930
|
+
let attempts = 0;
|
|
115931
|
+
while (attempts < maxAttempts) {
|
|
115932
|
+
try {
|
|
115933
|
+
execSync(`docker exec ${this.containerNames.mysql} mysqladmin ping -h localhost -u root -ppassword 2>/dev/null`, { stdio: "pipe" });
|
|
115934
|
+
return;
|
|
115935
|
+
} catch {
|
|
115936
|
+
attempts++;
|
|
115937
|
+
await this.sleep(1000);
|
|
115938
|
+
}
|
|
115939
|
+
}
|
|
115940
|
+
throw new Error("MySQL failed to start within 30 seconds");
|
|
115941
|
+
}
|
|
115942
|
+
async waitForMySQLReady() {
|
|
115943
|
+
const maxAttempts = 30;
|
|
115944
|
+
let attempts = 0;
|
|
115945
|
+
while (attempts < maxAttempts) {
|
|
115946
|
+
try {
|
|
115947
|
+
execSync(`docker exec ${this.containerNames.mysql} mysql -h 127.0.0.1 -u wordpress -pwordpress -e "SELECT 1" 2>/dev/null`, { stdio: "pipe" });
|
|
115948
|
+
return;
|
|
115949
|
+
} catch {
|
|
115950
|
+
attempts++;
|
|
115951
|
+
await this.sleep(1000);
|
|
115952
|
+
}
|
|
115953
|
+
}
|
|
115954
|
+
throw new Error("MySQL failed to accept connections within 30 seconds");
|
|
115955
|
+
}
|
|
115956
|
+
async waitForWordPress() {
|
|
115957
|
+
const maxAttempts = 60;
|
|
115958
|
+
let attempts = 0;
|
|
115959
|
+
logger.info(" Waiting for WordPress...");
|
|
115960
|
+
while (attempts < maxAttempts) {
|
|
115961
|
+
try {
|
|
115962
|
+
const response = execSync(`curl -s -o /dev/null -w "%{http_code}" http://localhost:${this.config.port}`, { encoding: "utf8", stdio: "pipe" }).trim();
|
|
115963
|
+
if (response.length > 0) {
|
|
115964
|
+
return;
|
|
115965
|
+
}
|
|
115966
|
+
} catch {}
|
|
115967
|
+
attempts++;
|
|
115968
|
+
await this.sleep(1000);
|
|
115969
|
+
}
|
|
115970
|
+
throw new Error("WordPress failed to start within 60 seconds");
|
|
115971
|
+
}
|
|
115972
|
+
async installWPCLI() {
|
|
115973
|
+
logger.info(" Installing WP-CLI...");
|
|
115974
|
+
try {
|
|
115975
|
+
execSync(`docker exec ${this.containerNames.wordpress} sh -c "curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && chmod +x wp-cli.phar && mv wp-cli.phar /usr/local/bin/wp"`, { stdio: "pipe" });
|
|
115976
|
+
} catch (error) {
|
|
115977
|
+
throw new Error(`Failed to install WP-CLI: ${error.message}`);
|
|
115978
|
+
}
|
|
115979
|
+
}
|
|
115980
|
+
async hasWPCLI() {
|
|
115981
|
+
try {
|
|
115982
|
+
execSync(`docker exec ${this.containerNames.wordpress} wp --version --allow-root 2>/dev/null`, { stdio: "pipe" });
|
|
115983
|
+
return true;
|
|
115984
|
+
} catch {
|
|
115985
|
+
return false;
|
|
115986
|
+
}
|
|
115987
|
+
}
|
|
115988
|
+
async isWordPressInstalled() {
|
|
115989
|
+
if (!await this.hasWPCLI()) {
|
|
115990
|
+
await this.installWPCLI();
|
|
115991
|
+
}
|
|
115992
|
+
try {
|
|
115993
|
+
execSync(`docker exec ${this.containerNames.wordpress} wp core is-installed --allow-root 2>/dev/null`, { stdio: "pipe", encoding: "utf8" });
|
|
115994
|
+
return true;
|
|
115995
|
+
} catch {
|
|
115996
|
+
return false;
|
|
115997
|
+
}
|
|
115998
|
+
}
|
|
115999
|
+
async installWordPress() {
|
|
116000
|
+
logger.info(" Installing WordPress...");
|
|
116001
|
+
const siteUrl = `http://localhost:${this.config.port}`;
|
|
116002
|
+
const themeName = path16.basename(path16.resolve(this.workspaceDir, this.config.themeDir));
|
|
116003
|
+
execSync(`docker exec ${this.containerNames.wordpress} wp core install --url="${siteUrl}" --title="Development Site" --admin_user=admin --admin_password=password --admin_email=admin@example.com --skip-email --allow-root`, { stdio: "pipe" });
|
|
116004
|
+
logger.info(` Activating theme: ${themeName}...`);
|
|
116005
|
+
try {
|
|
116006
|
+
execSync(`docker exec ${this.containerNames.wordpress} wp theme activate ${themeName} --allow-root`, { stdio: "pipe" });
|
|
116007
|
+
} catch (error) {
|
|
116008
|
+
logger.warn(` Could not activate theme: ${themeName}`);
|
|
116009
|
+
}
|
|
116010
|
+
execSync(`docker exec ${this.containerNames.wordpress} wp rewrite structure '/%postname%/' --allow-root`, { stdio: "pipe" });
|
|
116011
|
+
}
|
|
116012
|
+
async installPlugins() {
|
|
116013
|
+
if (this.config.plugins.length === 0)
|
|
116014
|
+
return;
|
|
116015
|
+
logger.info(" Installing plugins...");
|
|
116016
|
+
for (const plugin of this.config.plugins) {
|
|
116017
|
+
try {
|
|
116018
|
+
if (plugin.startsWith("./") || plugin.startsWith("/")) {
|
|
116019
|
+
const pluginPath = path16.resolve(this.workspaceDir, plugin);
|
|
116020
|
+
const pluginName = path16.basename(pluginPath);
|
|
116021
|
+
execSync(`docker cp "${pluginPath}" ${this.containerNames.wordpress}:/var/www/html/wp-content/plugins/${pluginName}`, { stdio: "pipe" });
|
|
116022
|
+
execSync(`docker exec ${this.containerNames.wordpress} wp plugin activate ${pluginName} --allow-root`, { stdio: "pipe" });
|
|
116023
|
+
} else {
|
|
116024
|
+
execSync(`docker exec ${this.containerNames.wordpress} wp plugin install ${plugin} --activate --allow-root`, { stdio: "pipe" });
|
|
116025
|
+
}
|
|
116026
|
+
logger.info(` ✓ ${plugin}`);
|
|
116027
|
+
} catch (error) {
|
|
116028
|
+
logger.warn(` ✗ Failed to install: ${plugin}`);
|
|
116029
|
+
}
|
|
116030
|
+
}
|
|
116031
|
+
}
|
|
116032
|
+
async importSqlDump() {
|
|
116033
|
+
if (!this.config.sqlDump)
|
|
116034
|
+
return;
|
|
116035
|
+
const sqlPath = path16.resolve(this.workspaceDir, this.config.sqlDump);
|
|
116036
|
+
if (!fs14.existsSync(sqlPath)) {
|
|
116037
|
+
logger.warn(` SQL dump not found: ${sqlPath}`);
|
|
116038
|
+
return;
|
|
116039
|
+
}
|
|
116040
|
+
logger.info(" Importing SQL dump...");
|
|
116041
|
+
await this.waitForMySQLReady();
|
|
116042
|
+
execSync(`docker cp "${sqlPath}" ${this.containerNames.mysql}:/tmp/dump.sql`, { stdio: "pipe" });
|
|
116043
|
+
execSync(`docker exec ${this.containerNames.mysql} sh -c "mysql -h 127.0.0.1 -u wordpress -pwordpress wordpress < /tmp/dump.sql"`, { stdio: "pipe" });
|
|
116044
|
+
const siteUrl = `http://localhost:${this.config.port}`;
|
|
116045
|
+
execSync(`docker exec ${this.containerNames.wordpress} wp option update siteurl "${siteUrl}" --allow-root`, { stdio: "pipe" });
|
|
116046
|
+
execSync(`docker exec ${this.containerNames.wordpress} wp option update home "${siteUrl}" --allow-root`, { stdio: "pipe" });
|
|
116047
|
+
await this.reactivatePlugins();
|
|
116048
|
+
logger.info(" ✓ SQL dump imported");
|
|
116049
|
+
}
|
|
116050
|
+
async reactivatePlugins() {
|
|
116051
|
+
try {
|
|
116052
|
+
const pluginsOutput = execSync(`docker exec ${this.containerNames.wordpress} wp plugin list --field=name --status=inactive --allow-root 2>/dev/null`, { encoding: "utf8", stdio: "pipe" }).trim();
|
|
116053
|
+
if (!pluginsOutput)
|
|
116054
|
+
return;
|
|
116055
|
+
const inactivePlugins = pluginsOutput.split(`
|
|
116056
|
+
`).filter((p) => p.trim());
|
|
116057
|
+
if (inactivePlugins.length === 0)
|
|
116058
|
+
return;
|
|
116059
|
+
logger.info(" Reactivating plugins...");
|
|
116060
|
+
for (const plugin of inactivePlugins) {
|
|
116061
|
+
try {
|
|
116062
|
+
execSync(`docker exec ${this.containerNames.wordpress} wp plugin activate ${plugin} --allow-root`, { stdio: "pipe" });
|
|
116063
|
+
logger.info(` ✓ ${plugin}`);
|
|
116064
|
+
} catch {
|
|
116065
|
+
logger.warn(` ✗ Could not activate: ${plugin}`);
|
|
116066
|
+
}
|
|
116067
|
+
}
|
|
116068
|
+
} catch {}
|
|
116069
|
+
}
|
|
116070
|
+
async exportSqlDump(outputPath) {
|
|
116071
|
+
const status = await this.getContainerStatus();
|
|
116072
|
+
if (status.mysql !== "running") {
|
|
116073
|
+
throw new Error("MySQL container is not running. Start the environment first with `wordpress-flow dev`");
|
|
116074
|
+
}
|
|
116075
|
+
logger.info(" Exporting database...");
|
|
116076
|
+
const sqlContent = execSync(`docker exec ${this.containerNames.mysql} mysqldump -h 127.0.0.1 -u wordpress -pwordpress wordpress 2>/dev/null`, { encoding: "utf8", maxBuffer: 50 * 1024 * 1024 });
|
|
116077
|
+
const resolvedPath = path16.resolve(this.workspaceDir, outputPath);
|
|
116078
|
+
const dir = path16.dirname(resolvedPath);
|
|
116079
|
+
if (!fs14.existsSync(dir)) {
|
|
116080
|
+
fs14.mkdirSync(dir, { recursive: true });
|
|
116081
|
+
}
|
|
116082
|
+
fs14.writeFileSync(resolvedPath, sqlContent, "utf8");
|
|
116083
|
+
logger.info(` ✓ Database exported to ${outputPath}`);
|
|
116084
|
+
}
|
|
116085
|
+
async importSqlDumpFromFile(inputPath) {
|
|
116086
|
+
const status = await this.getContainerStatus();
|
|
116087
|
+
if (status.mysql !== "running") {
|
|
116088
|
+
throw new Error("MySQL container is not running. Start the environment first with `wordpress-flow dev`");
|
|
116089
|
+
}
|
|
116090
|
+
const sqlPath = path16.resolve(this.workspaceDir, inputPath);
|
|
116091
|
+
if (!fs14.existsSync(sqlPath)) {
|
|
116092
|
+
throw new Error(`SQL dump not found: ${sqlPath}`);
|
|
116093
|
+
}
|
|
116094
|
+
logger.info(" Importing SQL dump...");
|
|
116095
|
+
await this.waitForMySQLReady();
|
|
116096
|
+
execSync(`docker cp "${sqlPath}" ${this.containerNames.mysql}:/tmp/dump.sql`, {
|
|
116097
|
+
stdio: "pipe"
|
|
116098
|
+
});
|
|
116099
|
+
execSync(`docker exec ${this.containerNames.mysql} sh -c "mysql -h 127.0.0.1 -u wordpress -pwordpress wordpress < /tmp/dump.sql"`, { stdio: "pipe" });
|
|
116100
|
+
if (!await this.hasWPCLI()) {
|
|
116101
|
+
await this.installWPCLI();
|
|
116102
|
+
}
|
|
116103
|
+
const siteUrl = `http://localhost:${this.config.port}`;
|
|
116104
|
+
try {
|
|
116105
|
+
execSync(`docker exec ${this.containerNames.wordpress} wp option update siteurl "${siteUrl}" --allow-root`, { stdio: "pipe" });
|
|
116106
|
+
execSync(`docker exec ${this.containerNames.wordpress} wp option update home "${siteUrl}" --allow-root`, { stdio: "pipe" });
|
|
116107
|
+
} catch {
|
|
116108
|
+
logger.warn(" Could not update site URLs (WordPress may not be fully installed)");
|
|
116109
|
+
}
|
|
116110
|
+
logger.info(" ✓ SQL dump imported");
|
|
116111
|
+
}
|
|
116112
|
+
getDatabaseConfig() {
|
|
116113
|
+
return {
|
|
116114
|
+
host: "127.0.0.1",
|
|
116115
|
+
port: this.config.databasePort ?? 3306,
|
|
116116
|
+
database: "wordpress",
|
|
116117
|
+
username: "wordpress",
|
|
116118
|
+
password: "wordpress"
|
|
116119
|
+
};
|
|
116120
|
+
}
|
|
116121
|
+
getWordPressUrl() {
|
|
116122
|
+
return `http://localhost:${this.config.port}`;
|
|
116123
|
+
}
|
|
116124
|
+
sleep(ms) {
|
|
116125
|
+
return new Promise((resolve6) => setTimeout(resolve6, ms));
|
|
116126
|
+
}
|
|
116127
|
+
async cleanup() {
|
|
116128
|
+
logger.info("\uD83E\uDDF9 Cleaning up Docker environment...");
|
|
116129
|
+
try {
|
|
116130
|
+
execSync(`docker rm -f ${this.containerNames.wordpress}`, {
|
|
116131
|
+
stdio: "pipe"
|
|
116132
|
+
});
|
|
116133
|
+
} catch {}
|
|
116134
|
+
try {
|
|
116135
|
+
execSync(`docker rm -f ${this.containerNames.mysql}`, { stdio: "pipe" });
|
|
116136
|
+
} catch {}
|
|
116137
|
+
try {
|
|
116138
|
+
execSync(`docker network rm ${this.projectName}-network`, {
|
|
116139
|
+
stdio: "pipe"
|
|
116140
|
+
});
|
|
116141
|
+
} catch {}
|
|
116142
|
+
if (this.config.volumes.database) {
|
|
116143
|
+
try {
|
|
116144
|
+
execSync(`docker volume rm ${this.projectName}-mysql-data`, {
|
|
116145
|
+
stdio: "pipe"
|
|
116146
|
+
});
|
|
116147
|
+
} catch {}
|
|
116148
|
+
}
|
|
116149
|
+
if (this.config.volumes.uploads) {
|
|
116150
|
+
try {
|
|
116151
|
+
execSync(`docker volume rm ${this.projectName}-uploads`, {
|
|
116152
|
+
stdio: "pipe"
|
|
116153
|
+
});
|
|
116154
|
+
} catch {}
|
|
116155
|
+
}
|
|
116156
|
+
logger.info(" ✓ Cleanup complete");
|
|
116157
|
+
}
|
|
116158
|
+
}
|
|
116009
116159
|
// package.json
|
|
116010
116160
|
var package_default = {
|
|
116011
116161
|
name: "@wordpress-flow/cli",
|
|
116012
|
-
version: "1.1.
|
|
116162
|
+
version: "1.1.4",
|
|
116013
116163
|
type: "module",
|
|
116014
116164
|
description: "TypeScript-based WordPress block creation system",
|
|
116015
116165
|
main: "dist/index.js",
|
|
@@ -116062,7 +116212,7 @@ var package_default = {
|
|
|
116062
116212
|
|
|
116063
116213
|
// src/dev/dev-mode-orchestrator.ts
|
|
116064
116214
|
var __filename2 = fileURLToPath4(import.meta.url);
|
|
116065
|
-
var __dirname2 =
|
|
116215
|
+
var __dirname2 = path17.dirname(__filename2);
|
|
116066
116216
|
|
|
116067
116217
|
class DevModeOrchestrator {
|
|
116068
116218
|
configManager;
|
|
@@ -116080,6 +116230,7 @@ class DevModeOrchestrator {
|
|
|
116080
116230
|
phpGenerator;
|
|
116081
116231
|
blockRegistry;
|
|
116082
116232
|
pushCommand;
|
|
116233
|
+
dockerEnvManager;
|
|
116083
116234
|
options;
|
|
116084
116235
|
watchers = [];
|
|
116085
116236
|
isRunning = false;
|
|
@@ -116087,6 +116238,8 @@ class DevModeOrchestrator {
|
|
|
116087
116238
|
outputDir;
|
|
116088
116239
|
templatesDir;
|
|
116089
116240
|
templatesOutputDir;
|
|
116241
|
+
templatePartsDir;
|
|
116242
|
+
templatePartsOutputDir;
|
|
116090
116243
|
contentDir;
|
|
116091
116244
|
webpackConfig;
|
|
116092
116245
|
scriptsPath;
|
|
@@ -116102,6 +116255,7 @@ class DevModeOrchestrator {
|
|
|
116102
116255
|
autoPush: true,
|
|
116103
116256
|
buildTemplates: true,
|
|
116104
116257
|
verbose: false,
|
|
116258
|
+
skipEnv: false,
|
|
116105
116259
|
...options
|
|
116106
116260
|
};
|
|
116107
116261
|
this.configManager = ConfigManager.getInstance();
|
|
@@ -116122,16 +116276,30 @@ class DevModeOrchestrator {
|
|
|
116122
116276
|
});
|
|
116123
116277
|
}
|
|
116124
116278
|
async start() {
|
|
116125
|
-
|
|
116279
|
+
console.log(`
|
|
116280
|
+
\uD83D\uDE80 Starting dev mode...
|
|
116281
|
+
`);
|
|
116126
116282
|
try {
|
|
116283
|
+
console.log("\uD83D\uDCCB Loading configuration...");
|
|
116127
116284
|
await this.initializeConfig();
|
|
116285
|
+
const config = this.configManager.getConfig();
|
|
116286
|
+
if (config.env && !this.options.skipEnv) {
|
|
116287
|
+
console.log("\uD83D\uDC33 Setting up Docker environment...");
|
|
116288
|
+
await this.startDockerEnvironment();
|
|
116289
|
+
}
|
|
116290
|
+
console.log("⚙️ Initializing build system...");
|
|
116128
116291
|
this.initializeManagers();
|
|
116129
116292
|
if (this.options.autoPush) {
|
|
116293
|
+
console.log("\uD83D\uDD0C Connecting to WordPress...");
|
|
116130
116294
|
await this.connectWordPress();
|
|
116131
116295
|
}
|
|
116296
|
+
console.log("\uD83D\uDD0D Scanning blocks...");
|
|
116132
116297
|
const blocks = await this.scanBlocks();
|
|
116298
|
+
console.log("\uD83D\uDD17 Analyzing dependencies...");
|
|
116133
116299
|
await this.scanDependencies();
|
|
116300
|
+
console.log("\uD83D\uDD28 Running initial build...");
|
|
116134
116301
|
await this.performInitialBuild(blocks);
|
|
116302
|
+
console.log("\uD83D\uDC40 Starting file watchers...");
|
|
116135
116303
|
this.startWatchers();
|
|
116136
116304
|
this.isRunning = true;
|
|
116137
116305
|
this.ui.showWatching();
|
|
@@ -116142,23 +116310,70 @@ class DevModeOrchestrator {
|
|
|
116142
116310
|
throw error;
|
|
116143
116311
|
}
|
|
116144
116312
|
}
|
|
116313
|
+
async startDockerEnvironment() {
|
|
116314
|
+
const config = this.configManager.getConfig();
|
|
116315
|
+
if (!config.env)
|
|
116316
|
+
return;
|
|
116317
|
+
const packageJsonPath = path17.join(this.configManager.getConfigDir(), "package.json");
|
|
116318
|
+
let projectName = "wordpress-project";
|
|
116319
|
+
if (fs15.existsSync(packageJsonPath)) {
|
|
116320
|
+
try {
|
|
116321
|
+
const pkg = JSON.parse(fs15.readFileSync(packageJsonPath, "utf8"));
|
|
116322
|
+
projectName = pkg.name || projectName;
|
|
116323
|
+
} catch {}
|
|
116324
|
+
}
|
|
116325
|
+
this.dockerEnvManager = new DockerEnvManager({
|
|
116326
|
+
projectName,
|
|
116327
|
+
workspaceDir: this.configManager.getConfigDir(),
|
|
116328
|
+
config: config.env
|
|
116329
|
+
});
|
|
116330
|
+
try {
|
|
116331
|
+
const { wordpressUrl, isFirstRun } = await this.dockerEnvManager.start();
|
|
116332
|
+
if (isFirstRun) {
|
|
116333
|
+
const isInstalled = await this.dockerEnvManager.isWordPressInstalled();
|
|
116334
|
+
if (!isInstalled) {
|
|
116335
|
+
await this.dockerEnvManager.importSqlDump();
|
|
116336
|
+
const isInstalledAfterImport = await this.dockerEnvManager.isWordPressInstalled();
|
|
116337
|
+
if (!isInstalledAfterImport) {
|
|
116338
|
+
await this.dockerEnvManager.installWordPress();
|
|
116339
|
+
}
|
|
116340
|
+
}
|
|
116341
|
+
await this.dockerEnvManager.installPlugins();
|
|
116342
|
+
}
|
|
116343
|
+
logger.success(`WordPress running at ${wordpressUrl}`);
|
|
116344
|
+
logger.info(` Admin: ${wordpressUrl}/wp-admin (admin / password)`);
|
|
116345
|
+
if (config.env.databasePort) {
|
|
116346
|
+
logger.info(` Database: 127.0.0.1:${config.env.databasePort} (wordpress / wordpress)`);
|
|
116347
|
+
}
|
|
116348
|
+
} catch (error) {
|
|
116349
|
+
const errorMessage = error.message;
|
|
116350
|
+
console.error(`
|
|
116351
|
+
❌ ${errorMessage}
|
|
116352
|
+
`);
|
|
116353
|
+
process.exit(1);
|
|
116354
|
+
}
|
|
116355
|
+
}
|
|
116145
116356
|
async initializeConfig() {
|
|
116146
|
-
const
|
|
116147
|
-
this.blocksDir = this.configManager.resolvePath(
|
|
116148
|
-
this.outputDir = this.configManager.resolvePath(
|
|
116149
|
-
if (
|
|
116150
|
-
this.webpackConfig = this.configManager.resolvePath(
|
|
116357
|
+
const config = this.configManager.getConfig();
|
|
116358
|
+
this.blocksDir = this.configManager.resolvePath(config.build?.blocksDir || "./theme/blocks");
|
|
116359
|
+
this.outputDir = this.configManager.resolvePath(config.build?.outputDir || "./theme/dist");
|
|
116360
|
+
if (config.build?.webpackConfig) {
|
|
116361
|
+
this.webpackConfig = this.configManager.resolvePath(config.build.webpackConfig);
|
|
116151
116362
|
} else {
|
|
116152
|
-
this.webpackConfig =
|
|
116363
|
+
this.webpackConfig = path17.join(__dirname2, "..", "webpack.config.cjs");
|
|
116153
116364
|
}
|
|
116154
|
-
this.scriptsPath =
|
|
116155
|
-
this.contentDir = this.configManager.resolvePath(
|
|
116156
|
-
if (
|
|
116157
|
-
this.templatesDir = this.configManager.resolvePath(
|
|
116158
|
-
this.templatesOutputDir = this.configManager.resolvePath(
|
|
116365
|
+
this.scriptsPath = config.build?.scriptsPath ? this.configManager.resolvePath(config.build.scriptsPath) : undefined;
|
|
116366
|
+
this.contentDir = this.configManager.resolvePath(config.paths.mdxOutputDir);
|
|
116367
|
+
if (config.templates) {
|
|
116368
|
+
this.templatesDir = this.configManager.resolvePath(config.templates.templatesDir);
|
|
116369
|
+
this.templatesOutputDir = this.configManager.resolvePath(config.templates.outputDir);
|
|
116159
116370
|
}
|
|
116160
|
-
if (
|
|
116161
|
-
|
|
116371
|
+
if (config.templateParts) {
|
|
116372
|
+
this.templatePartsDir = this.configManager.resolvePath(config.templateParts.partsDir);
|
|
116373
|
+
this.templatePartsOutputDir = this.configManager.resolvePath(config.templateParts.outputDir);
|
|
116374
|
+
}
|
|
116375
|
+
if (!fs15.existsSync(this.outputDir)) {
|
|
116376
|
+
fs15.mkdirSync(this.outputDir, { recursive: true });
|
|
116162
116377
|
}
|
|
116163
116378
|
}
|
|
116164
116379
|
initializeManagers() {
|
|
@@ -116179,8 +116394,18 @@ class DevModeOrchestrator {
|
|
|
116179
116394
|
}
|
|
116180
116395
|
async connectWordPress() {
|
|
116181
116396
|
try {
|
|
116182
|
-
const
|
|
116183
|
-
|
|
116397
|
+
const config = this.configManager.getConfig();
|
|
116398
|
+
let wpConfig = config.wordpress;
|
|
116399
|
+
if (this.dockerEnvManager && config.env?.databasePort) {
|
|
116400
|
+
const dbConfig = this.dockerEnvManager.getDatabaseConfig();
|
|
116401
|
+
wpConfig = {
|
|
116402
|
+
type: "database",
|
|
116403
|
+
wordpressUrl: `http://localhost:${config.env.port || 8888}`,
|
|
116404
|
+
database: dbConfig
|
|
116405
|
+
};
|
|
116406
|
+
logger.info(` Using Docker database: ${dbConfig.host}:${dbConfig.port}`);
|
|
116407
|
+
}
|
|
116408
|
+
await this.connectionManager.createConnection(wpConfig);
|
|
116184
116409
|
this.pushCommand = new PushCommand(this.blockRegistry);
|
|
116185
116410
|
logger.success("WordPress connection established");
|
|
116186
116411
|
} catch (error) {
|
|
@@ -116190,7 +116415,7 @@ class DevModeOrchestrator {
|
|
|
116190
116415
|
}
|
|
116191
116416
|
}
|
|
116192
116417
|
async scanBlocks() {
|
|
116193
|
-
if (!
|
|
116418
|
+
if (!fs15.existsSync(this.blocksDir)) {
|
|
116194
116419
|
logger.warn(`Blocks directory not found: ${this.blocksDir}`);
|
|
116195
116420
|
return [];
|
|
116196
116421
|
}
|
|
@@ -116208,9 +116433,9 @@ class DevModeOrchestrator {
|
|
|
116208
116433
|
return blocks;
|
|
116209
116434
|
}
|
|
116210
116435
|
async scanDependencies() {
|
|
116211
|
-
await this.dependencyTracker.scanDependencies(this.templatesDir, this.contentDir);
|
|
116436
|
+
await this.dependencyTracker.scanDependencies(this.templatesDir, this.contentDir, this.templatePartsDir);
|
|
116212
116437
|
const stats = this.dependencyTracker.getStats();
|
|
116213
|
-
this.ui.showDependencyScan(stats.totalTemplates, stats.totalPages, stats.totalBlocks);
|
|
116438
|
+
this.ui.showDependencyScan(stats.totalTemplates + stats.totalTemplateParts, stats.totalPages, stats.totalBlocks);
|
|
116214
116439
|
}
|
|
116215
116440
|
async performInitialBuild(blocks) {
|
|
116216
116441
|
const startTime = Date.now();
|
|
@@ -116228,62 +116453,229 @@ class DevModeOrchestrator {
|
|
|
116228
116453
|
await this.componentRegistry.loadAllBlocks();
|
|
116229
116454
|
await this.blockRegistry.loadBuiltBlocks();
|
|
116230
116455
|
this.ui.showInitialBuildComplete(blocks.length, blocks.length, 0, Date.now() - startTime);
|
|
116456
|
+
} else {
|
|
116457
|
+
console.log(`\uD83D\uDCE6 Blocks to build: ${blocksToRebuild.map((b) => b.name).join(", ")}`);
|
|
116458
|
+
let successCount = 0;
|
|
116459
|
+
let failCount = 0;
|
|
116460
|
+
const blockScripts = new Map;
|
|
116461
|
+
const results = await this.workerPool.buildAll(blocksToRebuild, (completed, total, blockName, success) => {
|
|
116462
|
+
if (success) {
|
|
116463
|
+
console.log(` ✅ ${blockName} [${completed}/${total}]`);
|
|
116464
|
+
successCount++;
|
|
116465
|
+
} else {
|
|
116466
|
+
console.log(` ❌ ${blockName} failed [${completed}/${total}]`);
|
|
116467
|
+
failCount++;
|
|
116468
|
+
}
|
|
116469
|
+
});
|
|
116470
|
+
for (const result2 of results) {
|
|
116471
|
+
if (result2.success) {
|
|
116472
|
+
const block = blocksToRebuild.find((b) => b.name === result2.blockName);
|
|
116473
|
+
if (block) {
|
|
116474
|
+
const hash = this.hashManager.calculateSourceHash(block.filePath);
|
|
116475
|
+
this.hashManager.storeHash(block.name, hash);
|
|
116476
|
+
if (block.scripts && block.scripts.length > 0) {
|
|
116477
|
+
const scriptPaths = block.scripts.map((script) => `scripts/${path17.basename(script).replace(/\.ts$/, ".js")}`);
|
|
116478
|
+
blockScripts.set(block.name, scriptPaths);
|
|
116479
|
+
}
|
|
116480
|
+
}
|
|
116481
|
+
}
|
|
116482
|
+
}
|
|
116483
|
+
if (blockScripts.size > 0) {
|
|
116484
|
+
const phpPath = path17.join(path17.dirname(this.outputDir), "functions-blocks-scripts.php");
|
|
116485
|
+
this.phpGenerator.generateScriptRegistrationPHP(blockScripts, phpPath);
|
|
116486
|
+
}
|
|
116487
|
+
await this.generateTypeDefinitions();
|
|
116488
|
+
await this.componentRegistry.loadAllBlocks();
|
|
116489
|
+
await this.blockRegistry.loadBuiltBlocks();
|
|
116490
|
+
this.ui.showInitialBuildComplete(blocks.length, successCount + cachedCount, failCount, Date.now() - startTime);
|
|
116491
|
+
}
|
|
116492
|
+
if (this.options.buildTemplates && this.templatesDir && this.templatesOutputDir) {
|
|
116493
|
+
await this.performInitialTemplateBuild();
|
|
116494
|
+
}
|
|
116495
|
+
if (this.options.buildTemplates && this.templatePartsDir && this.templatePartsOutputDir) {
|
|
116496
|
+
await this.performInitialTemplatePartsBuild();
|
|
116497
|
+
}
|
|
116498
|
+
if (this.options.autoPush && this.pushCommand) {
|
|
116499
|
+
await this.performInitialContentPush();
|
|
116500
|
+
}
|
|
116501
|
+
}
|
|
116502
|
+
async performInitialContentPush() {
|
|
116503
|
+
if (!fs15.existsSync(this.contentDir))
|
|
116504
|
+
return;
|
|
116505
|
+
const postDir = path17.join(this.contentDir, "post");
|
|
116506
|
+
const pageDir = path17.join(this.contentDir, "page");
|
|
116507
|
+
const contentFiles = [];
|
|
116508
|
+
if (fs15.existsSync(postDir)) {
|
|
116509
|
+
contentFiles.push(...this.findMDXFiles(postDir));
|
|
116510
|
+
}
|
|
116511
|
+
if (fs15.existsSync(pageDir)) {
|
|
116512
|
+
contentFiles.push(...this.findMDXFiles(pageDir));
|
|
116513
|
+
}
|
|
116514
|
+
if (contentFiles.length === 0) {
|
|
116231
116515
|
return;
|
|
116232
116516
|
}
|
|
116233
|
-
console.log(
|
|
116517
|
+
console.log(`
|
|
116518
|
+
\uD83D\uDE80 Pushing ${contentFiles.length} content file(s)...`);
|
|
116234
116519
|
let successCount = 0;
|
|
116235
116520
|
let failCount = 0;
|
|
116236
|
-
const
|
|
116237
|
-
|
|
116238
|
-
|
|
116239
|
-
|
|
116521
|
+
for (const filePath2 of contentFiles) {
|
|
116522
|
+
const fileName = path17.basename(filePath2);
|
|
116523
|
+
this.ignoreFileTemporarily(filePath2);
|
|
116524
|
+
try {
|
|
116525
|
+
await this.pushPages([filePath2]);
|
|
116240
116526
|
successCount++;
|
|
116241
|
-
}
|
|
116242
|
-
console.log(` ❌ ${
|
|
116527
|
+
} catch (error) {
|
|
116528
|
+
console.log(` ❌ ${fileName}: ${error.message}`);
|
|
116243
116529
|
failCount++;
|
|
116244
116530
|
}
|
|
116531
|
+
}
|
|
116532
|
+
if (failCount === 0) {
|
|
116533
|
+
console.log(`✅ Pushed ${successCount} content file(s)
|
|
116534
|
+
`);
|
|
116535
|
+
} else {
|
|
116536
|
+
console.log(`⚠️ Pushed ${successCount} content file(s), ${failCount} failed
|
|
116537
|
+
`);
|
|
116538
|
+
}
|
|
116539
|
+
}
|
|
116540
|
+
async performInitialTemplateBuild() {
|
|
116541
|
+
if (!this.templatesDir || !this.templatesOutputDir)
|
|
116542
|
+
return;
|
|
116543
|
+
if (!fs15.existsSync(this.templatesDir))
|
|
116544
|
+
return;
|
|
116545
|
+
const templateFiles = this.findMDXFiles(this.templatesDir);
|
|
116546
|
+
if (templateFiles.length === 0) {
|
|
116547
|
+
logger.info("No templates found to build");
|
|
116548
|
+
return;
|
|
116549
|
+
}
|
|
116550
|
+
console.log(`
|
|
116551
|
+
\uD83D\uDCC4 Building ${templateFiles.length} template(s)...`);
|
|
116552
|
+
if (!fs15.existsSync(this.templatesOutputDir)) {
|
|
116553
|
+
fs15.mkdirSync(this.templatesOutputDir, { recursive: true });
|
|
116554
|
+
}
|
|
116555
|
+
const renderer = new OfficialMDXRenderer({
|
|
116556
|
+
blockRegistry: this.blockRegistry
|
|
116245
116557
|
});
|
|
116246
|
-
|
|
116247
|
-
|
|
116248
|
-
|
|
116249
|
-
|
|
116250
|
-
|
|
116251
|
-
|
|
116252
|
-
|
|
116253
|
-
|
|
116254
|
-
|
|
116255
|
-
|
|
116256
|
-
|
|
116558
|
+
renderer.initialize();
|
|
116559
|
+
let successCount = 0;
|
|
116560
|
+
let failCount = 0;
|
|
116561
|
+
for (const templatePath of templateFiles) {
|
|
116562
|
+
const templateName = path17.basename(templatePath, ".mdx");
|
|
116563
|
+
const relativePath = path17.relative(this.templatesDir, templatePath);
|
|
116564
|
+
try {
|
|
116565
|
+
const mdxContent = fs15.readFileSync(templatePath, "utf8");
|
|
116566
|
+
const cleanContent = this.removeFrontmatter(mdxContent);
|
|
116567
|
+
const html5 = await renderer.renderMDXToHTML(cleanContent);
|
|
116568
|
+
const cleanHTML = renderer.postProcessHTML(html5);
|
|
116569
|
+
const outputPath = path17.join(this.templatesOutputDir, `${templateName}.html`);
|
|
116570
|
+
fs15.writeFileSync(outputPath, cleanHTML, "utf8");
|
|
116571
|
+
console.log(` ✅ ${relativePath}`);
|
|
116572
|
+
successCount++;
|
|
116573
|
+
} catch (error) {
|
|
116574
|
+
console.log(` ❌ ${relativePath}: ${error.message}`);
|
|
116575
|
+
failCount++;
|
|
116257
116576
|
}
|
|
116258
116577
|
}
|
|
116259
|
-
if (
|
|
116260
|
-
|
|
116261
|
-
|
|
116578
|
+
if (failCount === 0) {
|
|
116579
|
+
console.log(`✅ Built ${successCount} template(s)`);
|
|
116580
|
+
} else {
|
|
116581
|
+
console.log(`⚠️ Built ${successCount} template(s), ${failCount} failed`);
|
|
116262
116582
|
}
|
|
116263
|
-
|
|
116264
|
-
|
|
116265
|
-
|
|
116266
|
-
|
|
116583
|
+
}
|
|
116584
|
+
async performInitialTemplatePartsBuild() {
|
|
116585
|
+
if (!this.templatePartsDir || !this.templatePartsOutputDir)
|
|
116586
|
+
return;
|
|
116587
|
+
if (!fs15.existsSync(this.templatePartsDir))
|
|
116588
|
+
return;
|
|
116589
|
+
const partFiles = this.findMDXFiles(this.templatePartsDir);
|
|
116590
|
+
if (partFiles.length === 0) {
|
|
116591
|
+
logger.info("No template-parts found to build");
|
|
116592
|
+
return;
|
|
116593
|
+
}
|
|
116594
|
+
console.log(`
|
|
116595
|
+
\uD83E\uDDE9 Building ${partFiles.length} template-part(s)...`);
|
|
116596
|
+
if (!fs15.existsSync(this.templatePartsOutputDir)) {
|
|
116597
|
+
fs15.mkdirSync(this.templatePartsOutputDir, { recursive: true });
|
|
116598
|
+
}
|
|
116599
|
+
const renderer = new OfficialMDXRenderer({
|
|
116600
|
+
blockRegistry: this.blockRegistry
|
|
116601
|
+
});
|
|
116602
|
+
renderer.initialize();
|
|
116603
|
+
let successCount = 0;
|
|
116604
|
+
let failCount = 0;
|
|
116605
|
+
for (const partPath of partFiles) {
|
|
116606
|
+
const partName = path17.basename(partPath, ".mdx");
|
|
116607
|
+
const relativePath = path17.relative(this.templatePartsDir, partPath);
|
|
116608
|
+
try {
|
|
116609
|
+
const mdxContent = fs15.readFileSync(partPath, "utf8");
|
|
116610
|
+
const cleanContent = this.removeFrontmatter(mdxContent);
|
|
116611
|
+
const html5 = await renderer.renderMDXToHTML(cleanContent);
|
|
116612
|
+
const cleanHTML = renderer.postProcessHTML(html5);
|
|
116613
|
+
const outputPath = path17.join(this.templatePartsOutputDir, `${partName}.html`);
|
|
116614
|
+
fs15.writeFileSync(outputPath, cleanHTML, "utf8");
|
|
116615
|
+
console.log(` ✅ ${relativePath}`);
|
|
116616
|
+
successCount++;
|
|
116617
|
+
} catch (error) {
|
|
116618
|
+
console.log(` ❌ ${relativePath}: ${error.message}`);
|
|
116619
|
+
failCount++;
|
|
116620
|
+
}
|
|
116621
|
+
}
|
|
116622
|
+
if (failCount === 0) {
|
|
116623
|
+
console.log(`✅ Built ${successCount} template-part(s)`);
|
|
116624
|
+
} else {
|
|
116625
|
+
console.log(`⚠️ Built ${successCount} template-part(s), ${failCount} failed`);
|
|
116626
|
+
}
|
|
116627
|
+
}
|
|
116628
|
+
findMDXFiles(dir) {
|
|
116629
|
+
const files = [];
|
|
116630
|
+
const entries = fs15.readdirSync(dir, { withFileTypes: true });
|
|
116631
|
+
for (const entry of entries) {
|
|
116632
|
+
const fullPath = path17.join(dir, entry.name);
|
|
116633
|
+
if (entry.isDirectory()) {
|
|
116634
|
+
files.push(...this.findMDXFiles(fullPath));
|
|
116635
|
+
} else if (entry.isFile() && entry.name.endsWith(".mdx")) {
|
|
116636
|
+
files.push(fullPath);
|
|
116637
|
+
}
|
|
116638
|
+
}
|
|
116639
|
+
return files;
|
|
116267
116640
|
}
|
|
116268
116641
|
startWatchers() {
|
|
116269
116642
|
this.startBlockWatcher();
|
|
116270
116643
|
if (this.templatesDir && this.options.buildTemplates) {
|
|
116271
116644
|
this.startTemplateWatcher();
|
|
116272
116645
|
}
|
|
116646
|
+
if (this.templatePartsDir && this.options.buildTemplates) {
|
|
116647
|
+
this.startTemplatePartWatcher();
|
|
116648
|
+
}
|
|
116273
116649
|
if (this.options.autoPush) {
|
|
116274
116650
|
this.startPageWatcher();
|
|
116275
116651
|
}
|
|
116276
116652
|
}
|
|
116277
|
-
|
|
116278
|
-
|
|
116279
|
-
|
|
116280
|
-
cwd: this.blocksDir,
|
|
116653
|
+
getWatcherOptions() {
|
|
116654
|
+
const isLinux = process.platform === "linux";
|
|
116655
|
+
return {
|
|
116281
116656
|
persistent: true,
|
|
116282
116657
|
ignoreInitial: true,
|
|
116658
|
+
ignored: [
|
|
116659
|
+
"**/node_modules/**",
|
|
116660
|
+
"**/.git/**",
|
|
116661
|
+
"**/dist/**",
|
|
116662
|
+
"**/build/**",
|
|
116663
|
+
"**/*.map"
|
|
116664
|
+
],
|
|
116665
|
+
usePolling: isLinux,
|
|
116666
|
+
interval: isLinux ? 300 : undefined,
|
|
116667
|
+
binaryInterval: isLinux ? 300 : undefined,
|
|
116283
116668
|
awaitWriteFinish: {
|
|
116284
116669
|
stabilityThreshold: 200,
|
|
116285
|
-
pollInterval:
|
|
116670
|
+
pollInterval: 100
|
|
116286
116671
|
}
|
|
116672
|
+
};
|
|
116673
|
+
}
|
|
116674
|
+
startBlockWatcher() {
|
|
116675
|
+
logger.debug(`Watching blocks: ${this.blocksDir}`);
|
|
116676
|
+
const watcher = $watch("**/*.{tsx,ts,jsx,js}", {
|
|
116677
|
+
cwd: this.blocksDir,
|
|
116678
|
+
...this.getWatcherOptions()
|
|
116287
116679
|
});
|
|
116288
116680
|
this.watchers.push(watcher);
|
|
116289
116681
|
watcher.on("add", (filePath2) => this.handleBlockFileEvent("add", filePath2)).on("change", (filePath2) => this.handleBlockFileEvent("change", filePath2)).on("unlink", (filePath2) => this.handleBlockFileEvent("unlink", filePath2)).on("error", (error) => logger.error("Block watcher error:", error));
|
|
@@ -116292,40 +116684,41 @@ class DevModeOrchestrator {
|
|
|
116292
116684
|
});
|
|
116293
116685
|
}
|
|
116294
116686
|
startTemplateWatcher() {
|
|
116295
|
-
if (!this.templatesDir || !
|
|
116687
|
+
if (!this.templatesDir || !fs15.existsSync(this.templatesDir))
|
|
116296
116688
|
return;
|
|
116297
116689
|
logger.debug(`Watching templates: ${this.templatesDir}`);
|
|
116298
116690
|
const watcher = $watch("**/*.mdx", {
|
|
116299
116691
|
cwd: this.templatesDir,
|
|
116300
|
-
|
|
116301
|
-
ignoreInitial: true,
|
|
116302
|
-
awaitWriteFinish: {
|
|
116303
|
-
stabilityThreshold: 200,
|
|
116304
|
-
pollInterval: 50
|
|
116305
|
-
}
|
|
116692
|
+
...this.getWatcherOptions()
|
|
116306
116693
|
});
|
|
116307
116694
|
this.watchers.push(watcher);
|
|
116308
116695
|
watcher.on("add", (filePath2) => this.handleTemplateFileEvent("add", filePath2)).on("change", (filePath2) => this.handleTemplateFileEvent("change", filePath2)).on("unlink", (filePath2) => this.handleTemplateFileEvent("unlink", filePath2)).on("error", (error) => logger.error("Template watcher error:", error));
|
|
116309
116696
|
}
|
|
116697
|
+
startTemplatePartWatcher() {
|
|
116698
|
+
if (!this.templatePartsDir || !fs15.existsSync(this.templatePartsDir))
|
|
116699
|
+
return;
|
|
116700
|
+
logger.debug(`Watching template-parts: ${this.templatePartsDir}`);
|
|
116701
|
+
const watcher = $watch("**/*.mdx", {
|
|
116702
|
+
cwd: this.templatePartsDir,
|
|
116703
|
+
...this.getWatcherOptions()
|
|
116704
|
+
});
|
|
116705
|
+
this.watchers.push(watcher);
|
|
116706
|
+
watcher.on("add", (filePath2) => this.handleTemplatePartFileEvent("add", filePath2)).on("change", (filePath2) => this.handleTemplatePartFileEvent("change", filePath2)).on("unlink", (filePath2) => this.handleTemplatePartFileEvent("unlink", filePath2)).on("error", (error) => logger.error("Template-part watcher error:", error));
|
|
116707
|
+
}
|
|
116310
116708
|
startPageWatcher() {
|
|
116311
|
-
if (!
|
|
116709
|
+
if (!fs15.existsSync(this.contentDir))
|
|
116312
116710
|
return;
|
|
116313
116711
|
logger.debug(`Watching pages: ${this.contentDir}`);
|
|
116314
116712
|
const watcher = $watch(["post/**/*.mdx", "page/**/*.mdx"], {
|
|
116315
116713
|
cwd: this.contentDir,
|
|
116316
|
-
|
|
116317
|
-
ignoreInitial: true,
|
|
116318
|
-
awaitWriteFinish: {
|
|
116319
|
-
stabilityThreshold: 200,
|
|
116320
|
-
pollInterval: 50
|
|
116321
|
-
}
|
|
116714
|
+
...this.getWatcherOptions()
|
|
116322
116715
|
});
|
|
116323
116716
|
this.watchers.push(watcher);
|
|
116324
116717
|
watcher.on("add", (filePath2) => this.handlePageFileEvent("add", filePath2)).on("change", (filePath2) => this.handlePageFileEvent("change", filePath2)).on("unlink", (filePath2) => this.handlePageFileEvent("unlink", filePath2)).on("error", (error) => logger.error("Page watcher error:", error));
|
|
116325
116718
|
}
|
|
116326
116719
|
handleBlockFileEvent(eventType, filePath2) {
|
|
116327
|
-
const fullPath =
|
|
116328
|
-
const fileName =
|
|
116720
|
+
const fullPath = path17.resolve(this.blocksDir, filePath2);
|
|
116721
|
+
const fileName = path17.basename(filePath2, path17.extname(filePath2));
|
|
116329
116722
|
const isMainBlock = this.blockFilePaths.has(fileName);
|
|
116330
116723
|
const parentBlock = this.importToBlock.get(fullPath);
|
|
116331
116724
|
if (isMainBlock) {
|
|
@@ -116337,7 +116730,7 @@ class DevModeOrchestrator {
|
|
|
116337
116730
|
}
|
|
116338
116731
|
}
|
|
116339
116732
|
handleTemplateFileEvent(eventType, filePath2) {
|
|
116340
|
-
const fullPath =
|
|
116733
|
+
const fullPath = path17.resolve(this.templatesDir, filePath2);
|
|
116341
116734
|
this.changeQueue.queueTemplateChange(fullPath, eventType);
|
|
116342
116735
|
if (eventType === "unlink") {
|
|
116343
116736
|
this.dependencyTracker.removeFile(fullPath);
|
|
@@ -116345,8 +116738,17 @@ class DevModeOrchestrator {
|
|
|
116345
116738
|
this.dependencyTracker.updateFileDependencies(fullPath, "template");
|
|
116346
116739
|
}
|
|
116347
116740
|
}
|
|
116741
|
+
handleTemplatePartFileEvent(eventType, filePath2) {
|
|
116742
|
+
const fullPath = path17.resolve(this.templatePartsDir, filePath2);
|
|
116743
|
+
this.changeQueue.queueTemplatePartChange(fullPath, eventType);
|
|
116744
|
+
if (eventType === "unlink") {
|
|
116745
|
+
this.dependencyTracker.removeFile(fullPath);
|
|
116746
|
+
} else {
|
|
116747
|
+
this.dependencyTracker.updateFileDependencies(fullPath, "templatePart");
|
|
116748
|
+
}
|
|
116749
|
+
}
|
|
116348
116750
|
handlePageFileEvent(eventType, filePath2) {
|
|
116349
|
-
const fullPath =
|
|
116751
|
+
const fullPath = path17.resolve(this.contentDir, filePath2);
|
|
116350
116752
|
if (this.ignoredFiles.has(fullPath)) {
|
|
116351
116753
|
logger.debug(`Ignoring self-triggered change: ${filePath2}`);
|
|
116352
116754
|
return;
|
|
@@ -116377,15 +116779,39 @@ class DevModeOrchestrator {
|
|
|
116377
116779
|
await this.buildBlocks(blockNames);
|
|
116378
116780
|
}
|
|
116379
116781
|
const cascade = this.dependencyTracker.getCascade(blockNames);
|
|
116782
|
+
await this.processDependentArtifacts(batch, cascade);
|
|
116783
|
+
}
|
|
116784
|
+
async processDependentArtifacts(batch, cascade) {
|
|
116380
116785
|
const allTemplates = [
|
|
116381
116786
|
...new Set([...batch.templates, ...cascade.templates])
|
|
116382
116787
|
];
|
|
116788
|
+
const allTemplateParts = [
|
|
116789
|
+
...new Set([...batch.templateParts, ...cascade.templateParts])
|
|
116790
|
+
];
|
|
116383
116791
|
const allPages = [...new Set([...batch.pages, ...cascade.pages])];
|
|
116384
116792
|
if (allTemplates.length > 0 && this.options.buildTemplates) {
|
|
116385
|
-
await this.
|
|
116793
|
+
await this.processArtifacts("template", allTemplates);
|
|
116794
|
+
}
|
|
116795
|
+
if (allTemplateParts.length > 0 && this.options.buildTemplates) {
|
|
116796
|
+
await this.processArtifacts("templatePart", allTemplateParts);
|
|
116386
116797
|
}
|
|
116387
116798
|
if (allPages.length > 0 && this.options.autoPush) {
|
|
116388
|
-
await this.
|
|
116799
|
+
await this.processArtifacts("page", allPages);
|
|
116800
|
+
}
|
|
116801
|
+
}
|
|
116802
|
+
async processArtifacts(type, paths) {
|
|
116803
|
+
switch (type) {
|
|
116804
|
+
case "template":
|
|
116805
|
+
await this.buildTemplates(paths);
|
|
116806
|
+
break;
|
|
116807
|
+
case "templatePart":
|
|
116808
|
+
await this.buildTemplateParts(paths);
|
|
116809
|
+
break;
|
|
116810
|
+
case "page":
|
|
116811
|
+
await this.pushPages(paths);
|
|
116812
|
+
break;
|
|
116813
|
+
default:
|
|
116814
|
+
logger.warn(`Unknown artifact type: ${type}`);
|
|
116389
116815
|
}
|
|
116390
116816
|
}
|
|
116391
116817
|
async buildBlocks(blockNames) {
|
|
@@ -116443,18 +116869,63 @@ class DevModeOrchestrator {
|
|
|
116443
116869
|
});
|
|
116444
116870
|
renderer.initialize();
|
|
116445
116871
|
for (const templatePath of templatePaths) {
|
|
116446
|
-
const templateName =
|
|
116872
|
+
const templateName = path17.basename(templatePath, ".mdx");
|
|
116873
|
+
const relativePath = this.templatesDir ? path17.relative(this.templatesDir, templatePath) : templateName;
|
|
116447
116874
|
const taskId = this.taskScheduler.scheduleTemplateBuild(templatePath, []);
|
|
116875
|
+
const startTime = Date.now();
|
|
116876
|
+
try {
|
|
116877
|
+
const mdxContent = fs15.readFileSync(templatePath, "utf8");
|
|
116878
|
+
const cleanContent = this.removeFrontmatter(mdxContent);
|
|
116879
|
+
const html5 = await renderer.renderMDXToHTML(cleanContent);
|
|
116880
|
+
const cleanHTML = renderer.postProcessHTML(html5);
|
|
116881
|
+
const outputPath = path17.join(this.templatesOutputDir, `${templateName}.html`);
|
|
116882
|
+
fs15.writeFileSync(outputPath, cleanHTML, "utf8");
|
|
116883
|
+
const duration = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
116884
|
+
console.log(`\uD83D\uDCC4 ${relativePath} → ✅ (${duration}s)`);
|
|
116885
|
+
this.taskScheduler.completeTask(taskId, true);
|
|
116886
|
+
} catch (error) {
|
|
116887
|
+
const errorMsg = error.message;
|
|
116888
|
+
if (errorMsg.length > 60) {
|
|
116889
|
+
console.log(`\uD83D\uDCC4 ${relativePath} → ❌`);
|
|
116890
|
+
console.log(` ${errorMsg}`);
|
|
116891
|
+
} else {
|
|
116892
|
+
console.log(`\uD83D\uDCC4 ${relativePath} → ❌ ${errorMsg}`);
|
|
116893
|
+
}
|
|
116894
|
+
this.taskScheduler.completeTask(taskId, false, null, errorMsg);
|
|
116895
|
+
}
|
|
116896
|
+
}
|
|
116897
|
+
}
|
|
116898
|
+
async buildTemplateParts(partPaths) {
|
|
116899
|
+
if (!this.templatePartsOutputDir)
|
|
116900
|
+
return;
|
|
116901
|
+
const renderer = new OfficialMDXRenderer({
|
|
116902
|
+
blockRegistry: this.blockRegistry
|
|
116903
|
+
});
|
|
116904
|
+
renderer.initialize();
|
|
116905
|
+
for (const partPath of partPaths) {
|
|
116906
|
+
const partName = path17.basename(partPath, ".mdx");
|
|
116907
|
+
const relativePath = this.templatePartsDir ? path17.relative(this.templatePartsDir, partPath) : partName;
|
|
116908
|
+
const taskId = this.taskScheduler.scheduleTemplateBuild(partPath, []);
|
|
116909
|
+
const startTime = Date.now();
|
|
116448
116910
|
try {
|
|
116449
|
-
const mdxContent =
|
|
116911
|
+
const mdxContent = fs15.readFileSync(partPath, "utf8");
|
|
116450
116912
|
const cleanContent = this.removeFrontmatter(mdxContent);
|
|
116451
116913
|
const html5 = await renderer.renderMDXToHTML(cleanContent);
|
|
116452
116914
|
const cleanHTML = renderer.postProcessHTML(html5);
|
|
116453
|
-
const outputPath =
|
|
116454
|
-
|
|
116915
|
+
const outputPath = path17.join(this.templatePartsOutputDir, `${partName}.html`);
|
|
116916
|
+
fs15.writeFileSync(outputPath, cleanHTML, "utf8");
|
|
116917
|
+
const duration = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
116918
|
+
console.log(`\uD83E\uDDE9 ${relativePath} → ✅ (${duration}s)`);
|
|
116455
116919
|
this.taskScheduler.completeTask(taskId, true);
|
|
116456
116920
|
} catch (error) {
|
|
116457
|
-
|
|
116921
|
+
const errorMsg = error.message;
|
|
116922
|
+
if (errorMsg.length > 60) {
|
|
116923
|
+
console.log(`\uD83E\uDDE9 ${relativePath} → ❌`);
|
|
116924
|
+
console.log(` ${errorMsg}`);
|
|
116925
|
+
} else {
|
|
116926
|
+
console.log(`\uD83E\uDDE9 ${relativePath} → ❌ ${errorMsg}`);
|
|
116927
|
+
}
|
|
116928
|
+
this.taskScheduler.completeTask(taskId, false, null, errorMsg);
|
|
116458
116929
|
}
|
|
116459
116930
|
}
|
|
116460
116931
|
}
|
|
@@ -116463,7 +116934,7 @@ class DevModeOrchestrator {
|
|
|
116463
116934
|
return;
|
|
116464
116935
|
for (const pagePath of pagePaths) {
|
|
116465
116936
|
const taskId = this.taskScheduler.schedulePagePush(pagePath, []);
|
|
116466
|
-
const fileName =
|
|
116937
|
+
const fileName = path17.basename(pagePath);
|
|
116467
116938
|
const startTime = Date.now();
|
|
116468
116939
|
this.ignoreFileTemporarily(pagePath);
|
|
116469
116940
|
try {
|
|
@@ -116491,7 +116962,7 @@ class DevModeOrchestrator {
|
|
|
116491
116962
|
try {
|
|
116492
116963
|
const blocks = await this.typeGenerator.extractBlocksFromDist(this.outputDir);
|
|
116493
116964
|
if (blocks.length > 0) {
|
|
116494
|
-
const typesPath =
|
|
116965
|
+
const typesPath = path17.join(this.outputDir, "blocks.d.ts");
|
|
116495
116966
|
await this.typeGenerator.generateDefinitions(blocks, typesPath);
|
|
116496
116967
|
}
|
|
116497
116968
|
} catch (error) {
|
|
@@ -116516,6 +116987,11 @@ class DevModeOrchestrator {
|
|
|
116516
116987
|
try {
|
|
116517
116988
|
await this.connectionManager.closeConnection();
|
|
116518
116989
|
} catch {}
|
|
116990
|
+
if (this.dockerEnvManager) {
|
|
116991
|
+
try {
|
|
116992
|
+
await this.dockerEnvManager.stop();
|
|
116993
|
+
} catch {}
|
|
116994
|
+
}
|
|
116519
116995
|
this.ui.showShutdownComplete();
|
|
116520
116996
|
process.exit(0);
|
|
116521
116997
|
};
|
|
@@ -116541,7 +117017,8 @@ class DevCommand {
|
|
|
116541
117017
|
concurrency: options.concurrency,
|
|
116542
117018
|
autoPush: options.push !== false,
|
|
116543
117019
|
buildTemplates: options.templates !== false,
|
|
116544
|
-
verbose: options.verbose ?? false
|
|
117020
|
+
verbose: options.verbose ?? false,
|
|
117021
|
+
skipEnv: options.skipEnv ?? false
|
|
116545
117022
|
};
|
|
116546
117023
|
this.orchestrator = new DevModeOrchestrator(devOptions);
|
|
116547
117024
|
try {
|
|
@@ -116559,37 +117036,37 @@ class DevCommand {
|
|
|
116559
117036
|
}
|
|
116560
117037
|
|
|
116561
117038
|
// src/commands/build-command.ts
|
|
116562
|
-
import * as
|
|
117039
|
+
import * as path22 from "path";
|
|
116563
117040
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
116564
117041
|
|
|
116565
117042
|
// src/build/block-builder.ts
|
|
116566
|
-
import * as
|
|
116567
|
-
import * as
|
|
117043
|
+
import * as fs18 from "fs";
|
|
117044
|
+
import * as path20 from "path";
|
|
116568
117045
|
|
|
116569
117046
|
// src/build/webpack-runner.ts
|
|
116570
|
-
import * as
|
|
116571
|
-
import * as
|
|
116572
|
-
import { execSync } from "child_process";
|
|
117047
|
+
import * as path18 from "path";
|
|
117048
|
+
import * as fs16 from "fs";
|
|
117049
|
+
import { execSync as execSync2 } from "child_process";
|
|
116573
117050
|
var import_chalk3 = __toESM(require_source(), 1);
|
|
116574
117051
|
|
|
116575
117052
|
class WebpackRunner {
|
|
116576
117053
|
async runBuild(entryPoint, outputDir, webpackConfigPath) {
|
|
116577
117054
|
logger.debug(`Running webpack build for: ${entryPoint}`);
|
|
116578
|
-
if (!
|
|
117055
|
+
if (!fs16.existsSync(webpackConfigPath)) {
|
|
116579
117056
|
const error = `Webpack config not found: ${webpackConfigPath}`;
|
|
116580
117057
|
console.error(import_chalk3.default.red(`
|
|
116581
117058
|
❌ ${error}
|
|
116582
117059
|
`));
|
|
116583
117060
|
throw new Error(error);
|
|
116584
117061
|
}
|
|
116585
|
-
if (!
|
|
117062
|
+
if (!fs16.existsSync(entryPoint)) {
|
|
116586
117063
|
const error = `Entry point not found: ${entryPoint}`;
|
|
116587
117064
|
console.error(import_chalk3.default.red(`
|
|
116588
117065
|
❌ ${error}
|
|
116589
117066
|
`));
|
|
116590
117067
|
throw new Error(error);
|
|
116591
117068
|
}
|
|
116592
|
-
|
|
117069
|
+
fs16.mkdirSync(outputDir, { recursive: true });
|
|
116593
117070
|
const webpackBinary = this.findWebpackBinary();
|
|
116594
117071
|
logger.debug(`Using webpack binary: ${webpackBinary}`);
|
|
116595
117072
|
const envVars = {
|
|
@@ -116600,9 +117077,9 @@ class WebpackRunner {
|
|
|
116600
117077
|
const command = `${webpackBinary} --config "${webpackConfigPath}" ${envString} --mode production`;
|
|
116601
117078
|
logger.debug(`Full command: ${command}`);
|
|
116602
117079
|
try {
|
|
116603
|
-
const workingDir =
|
|
117080
|
+
const workingDir = path18.dirname(webpackConfigPath);
|
|
116604
117081
|
logger.debug(`Running webpack from directory: ${workingDir}`);
|
|
116605
|
-
const output2 =
|
|
117082
|
+
const output2 = execSync2(command, {
|
|
116606
117083
|
cwd: workingDir,
|
|
116607
117084
|
encoding: "utf8",
|
|
116608
117085
|
stdio: "pipe"
|
|
@@ -116619,7 +117096,7 @@ class WebpackRunner {
|
|
|
116619
117096
|
console.error(import_chalk3.default.gray(command));
|
|
116620
117097
|
console.error("");
|
|
116621
117098
|
console.error(import_chalk3.default.yellow("Working directory:"));
|
|
116622
|
-
console.error(import_chalk3.default.gray(
|
|
117099
|
+
console.error(import_chalk3.default.gray(path18.dirname(webpackConfigPath)));
|
|
116623
117100
|
console.error("");
|
|
116624
117101
|
if (error.stdout && error.stdout.trim()) {
|
|
116625
117102
|
console.error(import_chalk3.default.yellow("Standard output:"));
|
|
@@ -116643,13 +117120,13 @@ class WebpackRunner {
|
|
|
116643
117120
|
}
|
|
116644
117121
|
findWebpackBinary() {
|
|
116645
117122
|
const possiblePaths = [
|
|
116646
|
-
|
|
116647
|
-
|
|
116648
|
-
|
|
116649
|
-
|
|
117123
|
+
path18.join(process.cwd(), "packages", "block", "node_modules", ".bin", "webpack"),
|
|
117124
|
+
path18.join(process.cwd(), "node_modules", ".bin", "webpack"),
|
|
117125
|
+
path18.join(import.meta.dirname, "..", "..", "..", "node_modules", ".bin", "webpack"),
|
|
117126
|
+
path18.join(process.cwd(), "..", "node_modules", ".bin", "webpack")
|
|
116650
117127
|
];
|
|
116651
117128
|
for (const webpackPath of possiblePaths) {
|
|
116652
|
-
if (
|
|
117129
|
+
if (fs16.existsSync(webpackPath)) {
|
|
116653
117130
|
logger.debug(`Found webpack at: ${webpackPath}`);
|
|
116654
117131
|
return webpackPath;
|
|
116655
117132
|
}
|
|
@@ -116660,15 +117137,15 @@ class WebpackRunner {
|
|
|
116660
117137
|
}
|
|
116661
117138
|
|
|
116662
117139
|
// src/build/script-builder.ts
|
|
116663
|
-
import * as
|
|
116664
|
-
import * as
|
|
117140
|
+
import * as fs17 from "fs";
|
|
117141
|
+
import * as path19 from "path";
|
|
116665
117142
|
import * as esbuild from "esbuild";
|
|
116666
117143
|
class ScriptBuilder {
|
|
116667
117144
|
async buildScript(scriptPath, outputDir, scriptName) {
|
|
116668
117145
|
try {
|
|
116669
117146
|
logger.debug(`Building script: ${scriptName}`);
|
|
116670
|
-
|
|
116671
|
-
const outputPath =
|
|
117147
|
+
fs17.mkdirSync(outputDir, { recursive: true });
|
|
117148
|
+
const outputPath = path19.join(outputDir, scriptName.replace(/\.ts$/, ".js"));
|
|
116672
117149
|
await esbuild.build({
|
|
116673
117150
|
entryPoints: [scriptPath],
|
|
116674
117151
|
outfile: outputPath,
|
|
@@ -116698,19 +117175,19 @@ class ScriptBuilder {
|
|
|
116698
117175
|
async buildScripts(scripts, scriptsPath, outputDir) {
|
|
116699
117176
|
const outputPaths = [];
|
|
116700
117177
|
for (const script of scripts) {
|
|
116701
|
-
const scriptPath =
|
|
116702
|
-
if (!
|
|
117178
|
+
const scriptPath = path19.resolve(scriptsPath, script);
|
|
117179
|
+
if (!fs17.existsSync(scriptPath)) {
|
|
116703
117180
|
logger.warn(`Script not found: ${scriptPath}`);
|
|
116704
117181
|
continue;
|
|
116705
117182
|
}
|
|
116706
|
-
const scriptName =
|
|
117183
|
+
const scriptName = path19.basename(script);
|
|
116707
117184
|
const outputPath = await this.buildScript(scriptPath, outputDir, scriptName);
|
|
116708
117185
|
outputPaths.push(outputPath);
|
|
116709
117186
|
}
|
|
116710
117187
|
return outputPaths;
|
|
116711
117188
|
}
|
|
116712
117189
|
getRelativeScriptPath(blockDistPath, scriptPath) {
|
|
116713
|
-
const relativePath =
|
|
117190
|
+
const relativePath = path19.relative(blockDistPath, scriptPath);
|
|
116714
117191
|
return relativePath.replace(/\\/g, "/");
|
|
116715
117192
|
}
|
|
116716
117193
|
}
|
|
@@ -116724,17 +117201,17 @@ class BlockBuilder {
|
|
|
116724
117201
|
constructor() {
|
|
116725
117202
|
this.webpackRunner = new WebpackRunner;
|
|
116726
117203
|
this.scriptBuilder = new ScriptBuilder;
|
|
116727
|
-
this.tempDir =
|
|
117204
|
+
this.tempDir = path20.join(process.cwd(), ".wordpress-flow-temp");
|
|
116728
117205
|
}
|
|
116729
117206
|
async buildBlock(block, outputDir, webpackConfigPath, scriptsPath) {
|
|
116730
117207
|
logger.debug(`Building block: ${block.name}`);
|
|
116731
|
-
|
|
117208
|
+
fs18.mkdirSync(this.tempDir, { recursive: true });
|
|
116732
117209
|
try {
|
|
116733
117210
|
logger.debug(`[1/6] Generating entry point...`);
|
|
116734
117211
|
const entryPoint = await this.generateEntryPoint(block);
|
|
116735
117212
|
logger.debug(`[2/6] Creating output directory...`);
|
|
116736
|
-
const blockOutputDir =
|
|
116737
|
-
|
|
117213
|
+
const blockOutputDir = path20.join(outputDir, block.name);
|
|
117214
|
+
fs18.mkdirSync(blockOutputDir, { recursive: true });
|
|
116738
117215
|
let scriptPaths = [];
|
|
116739
117216
|
if (block.scripts && block.scripts.length > 0 && scriptsPath) {
|
|
116740
117217
|
logger.debug(`[3/6] Building ${block.scripts.length} script(s)...`);
|
|
@@ -116761,7 +117238,7 @@ class BlockBuilder {
|
|
|
116761
117238
|
}
|
|
116762
117239
|
}
|
|
116763
117240
|
async buildBlockScripts(scripts, scriptsPath, outputDir) {
|
|
116764
|
-
const scriptsOutputDir =
|
|
117241
|
+
const scriptsOutputDir = path20.join(path20.dirname(outputDir), "scripts");
|
|
116765
117242
|
return await this.scriptBuilder.buildScripts(scripts, scriptsPath, scriptsOutputDir);
|
|
116766
117243
|
}
|
|
116767
117244
|
async generateEntryPoint(block) {
|
|
@@ -116785,14 +117262,14 @@ if (document.readyState === 'loading') {
|
|
|
116785
117262
|
blockInstance.register();
|
|
116786
117263
|
}
|
|
116787
117264
|
`;
|
|
116788
|
-
const entryPath =
|
|
116789
|
-
|
|
117265
|
+
const entryPath = path20.join(this.tempDir, `${block.name}-entry.js`);
|
|
117266
|
+
fs18.writeFileSync(entryPath, entryContent, "utf8");
|
|
116790
117267
|
return entryPath;
|
|
116791
117268
|
}
|
|
116792
117269
|
async generateSSRVersion(block, outputDir) {
|
|
116793
117270
|
try {
|
|
116794
117271
|
logger.debug(`Generating SSR version for ${block.name} using esbuild`);
|
|
116795
|
-
const ssrPath =
|
|
117272
|
+
const ssrPath = path20.join(outputDir, "ssr.js");
|
|
116796
117273
|
await esbuild2.build({
|
|
116797
117274
|
entryPoints: [block.filePath],
|
|
116798
117275
|
outfile: ssrPath,
|
|
@@ -116832,8 +117309,8 @@ if (document.readyState === 'loading') {
|
|
|
116832
117309
|
throw new Error(`Block ${block.name} must export a valid block instance with toBlockJson() method`);
|
|
116833
117310
|
}
|
|
116834
117311
|
const blockJson = blockInstance.toBlockJson();
|
|
116835
|
-
const blockJsonPath =
|
|
116836
|
-
|
|
117312
|
+
const blockJsonPath = path20.join(outputDir, "block.json");
|
|
117313
|
+
fs18.writeFileSync(blockJsonPath, JSON.stringify(blockJson, null, 2), "utf8");
|
|
116837
117314
|
logger.debug(`Generated block.json for ${block.name}`);
|
|
116838
117315
|
} catch (error) {
|
|
116839
117316
|
logger.error(`Failed to generate block.json for ${block.name}:`, error);
|
|
@@ -116856,8 +117333,8 @@ if (document.readyState === 'loading') {
|
|
|
116856
117333
|
editorStyle: "file:./index.css",
|
|
116857
117334
|
style: "file:./style-index.css"
|
|
116858
117335
|
};
|
|
116859
|
-
const blockJsonPath =
|
|
116860
|
-
|
|
117336
|
+
const blockJsonPath = path20.join(outputDir, "block.json");
|
|
117337
|
+
fs18.writeFileSync(blockJsonPath, JSON.stringify(fallbackBlockJson, null, 2), "utf8");
|
|
116861
117338
|
logger.warn(`Used fallback block.json for ${block.name}`);
|
|
116862
117339
|
}
|
|
116863
117340
|
}
|
|
@@ -116869,7 +117346,7 @@ if (document.readyState === 'loading') {
|
|
|
116869
117346
|
}
|
|
116870
117347
|
async compileAndImport(filePath2) {
|
|
116871
117348
|
try {
|
|
116872
|
-
const tempFile =
|
|
117349
|
+
const tempFile = path20.join(this.tempDir, `${path20.basename(filePath2, path20.extname(filePath2))}-compiled.js`);
|
|
116873
117350
|
logger.debug(`Compiling ${filePath2} to ${tempFile}`);
|
|
116874
117351
|
if (typeof global.React === "undefined") {
|
|
116875
117352
|
global.React = require_react();
|
|
@@ -116898,8 +117375,8 @@ if (document.readyState === 'loading') {
|
|
|
116898
117375
|
}
|
|
116899
117376
|
}
|
|
116900
117377
|
parseBlockFromSource(filePath2) {
|
|
116901
|
-
const content4 =
|
|
116902
|
-
const blockName =
|
|
117378
|
+
const content4 = fs18.readFileSync(filePath2, "utf8");
|
|
117379
|
+
const blockName = path20.basename(filePath2, ".tsx");
|
|
116903
117380
|
const blockData = this.extractBlockDataFromSource(content4, filePath2);
|
|
116904
117381
|
return {
|
|
116905
117382
|
toBlockJson: () => {
|
|
@@ -117009,22 +117486,22 @@ if (document.readyState === 'loading') {
|
|
|
117009
117486
|
const requiredFiles = ["block.json", "index.js", "ssr.js"];
|
|
117010
117487
|
const optionalFiles = ["index.asset.php", "index.css", "style-index.css"];
|
|
117011
117488
|
for (const file of requiredFiles) {
|
|
117012
|
-
const filePath2 =
|
|
117013
|
-
if (!
|
|
117489
|
+
const filePath2 = path20.join(outputDir, file);
|
|
117490
|
+
if (!fs18.existsSync(filePath2)) {
|
|
117014
117491
|
throw new Error(`Required build output file missing: ${file}`);
|
|
117015
117492
|
}
|
|
117016
117493
|
}
|
|
117017
117494
|
for (const file of optionalFiles) {
|
|
117018
|
-
const filePath2 =
|
|
117019
|
-
if (
|
|
117495
|
+
const filePath2 = path20.join(outputDir, file);
|
|
117496
|
+
if (fs18.existsSync(filePath2)) {
|
|
117020
117497
|
logger.debug(`Generated optional file: ${file}`);
|
|
117021
117498
|
}
|
|
117022
117499
|
}
|
|
117023
117500
|
}
|
|
117024
117501
|
cleanupTempFiles() {
|
|
117025
117502
|
try {
|
|
117026
|
-
if (
|
|
117027
|
-
|
|
117503
|
+
if (fs18.existsSync(this.tempDir)) {
|
|
117504
|
+
fs18.rmSync(this.tempDir, { recursive: true, force: true });
|
|
117028
117505
|
}
|
|
117029
117506
|
} catch (error) {
|
|
117030
117507
|
logger.warn("Failed to clean up temp files:", error);
|
|
@@ -117034,7 +117511,7 @@ if (document.readyState === 'loading') {
|
|
|
117034
117511
|
|
|
117035
117512
|
// src/build/worker-pool.ts
|
|
117036
117513
|
import { Worker as Worker2 } from "worker_threads";
|
|
117037
|
-
import * as
|
|
117514
|
+
import * as path21 from "path";
|
|
117038
117515
|
import * as os2 from "os";
|
|
117039
117516
|
class WorkerPool {
|
|
117040
117517
|
concurrency;
|
|
@@ -117047,7 +117524,7 @@ class WorkerPool {
|
|
|
117047
117524
|
this.outputDir = options.outputDir;
|
|
117048
117525
|
this.webpackConfigPath = options.webpackConfigPath;
|
|
117049
117526
|
this.scriptsPath = options.scriptsPath;
|
|
117050
|
-
this.workerPath =
|
|
117527
|
+
this.workerPath = path21.join(import.meta.dirname, "build", "block-build-worker.js");
|
|
117051
117528
|
}
|
|
117052
117529
|
async buildAll(blocks, onProgress) {
|
|
117053
117530
|
const results = [];
|
|
@@ -117056,7 +117533,7 @@ class WorkerPool {
|
|
|
117056
117533
|
const total = blocks.length;
|
|
117057
117534
|
let activeWorkers = 0;
|
|
117058
117535
|
logger.info(`Building ${total} block(s) with ${this.concurrency} worker(s)`);
|
|
117059
|
-
return new Promise((
|
|
117536
|
+
return new Promise((resolve8, reject) => {
|
|
117060
117537
|
const processNext = () => {
|
|
117061
117538
|
while (activeWorkers < this.concurrency && queue.length > 0) {
|
|
117062
117539
|
const block = queue.shift();
|
|
@@ -117069,7 +117546,7 @@ class WorkerPool {
|
|
|
117069
117546
|
if (queue.length > 0) {
|
|
117070
117547
|
processNext();
|
|
117071
117548
|
} else if (activeWorkers === 0) {
|
|
117072
|
-
|
|
117549
|
+
resolve8(results);
|
|
117073
117550
|
}
|
|
117074
117551
|
}).catch((error) => {
|
|
117075
117552
|
const result2 = {
|
|
@@ -117084,7 +117561,7 @@ class WorkerPool {
|
|
|
117084
117561
|
if (queue.length > 0) {
|
|
117085
117562
|
processNext();
|
|
117086
117563
|
} else if (activeWorkers === 0) {
|
|
117087
|
-
|
|
117564
|
+
resolve8(results);
|
|
117088
117565
|
}
|
|
117089
117566
|
});
|
|
117090
117567
|
}
|
|
@@ -117093,8 +117570,8 @@ class WorkerPool {
|
|
|
117093
117570
|
});
|
|
117094
117571
|
}
|
|
117095
117572
|
buildBlockInWorker(block) {
|
|
117096
|
-
return new Promise((
|
|
117097
|
-
const tempDir =
|
|
117573
|
+
return new Promise((resolve8, reject) => {
|
|
117574
|
+
const tempDir = path21.join(process.cwd(), ".wordpress-flow-temp", `worker-${block.name}-${Date.now()}`);
|
|
117098
117575
|
const workerData = {
|
|
117099
117576
|
block: {
|
|
117100
117577
|
name: block.name,
|
|
@@ -117114,7 +117591,7 @@ class WorkerPool {
|
|
|
117114
117591
|
worker.on("message", (result2) => {
|
|
117115
117592
|
clearTimeout(timeout);
|
|
117116
117593
|
worker.terminate();
|
|
117117
|
-
|
|
117594
|
+
resolve8(result2);
|
|
117118
117595
|
});
|
|
117119
117596
|
worker.on("error", (error) => {
|
|
117120
117597
|
clearTimeout(timeout);
|
|
@@ -117133,7 +117610,7 @@ class WorkerPool {
|
|
|
117133
117610
|
|
|
117134
117611
|
// src/commands/build-command.ts
|
|
117135
117612
|
var __filename3 = fileURLToPath5(import.meta.url);
|
|
117136
|
-
var __dirname3 =
|
|
117613
|
+
var __dirname3 = path22.dirname(__filename3);
|
|
117137
117614
|
|
|
117138
117615
|
class BuildCommand {
|
|
117139
117616
|
configManager;
|
|
@@ -117153,18 +117630,18 @@ class BuildCommand {
|
|
|
117153
117630
|
async execute(options) {
|
|
117154
117631
|
logger.progress("Starting build operation...");
|
|
117155
117632
|
try {
|
|
117156
|
-
const
|
|
117157
|
-
const blocksDir = this.configManager.resolvePath(options.blocksDir ||
|
|
117158
|
-
const outputDir = this.configManager.resolvePath(options.outputDir ||
|
|
117633
|
+
const config = this.configManager.getConfig();
|
|
117634
|
+
const blocksDir = this.configManager.resolvePath(options.blocksDir || config.build?.blocksDir || "./theme/blocks");
|
|
117635
|
+
const outputDir = this.configManager.resolvePath(options.outputDir || config.build?.outputDir || "./theme/dist");
|
|
117159
117636
|
let webpackConfig;
|
|
117160
117637
|
if (options.webpackConfig) {
|
|
117161
117638
|
webpackConfig = this.configManager.resolvePath(options.webpackConfig);
|
|
117162
|
-
} else if (
|
|
117163
|
-
webpackConfig = this.configManager.resolvePath(
|
|
117639
|
+
} else if (config.build?.webpackConfig) {
|
|
117640
|
+
webpackConfig = this.configManager.resolvePath(config.build.webpackConfig);
|
|
117164
117641
|
} else {
|
|
117165
|
-
webpackConfig =
|
|
117642
|
+
webpackConfig = path22.join(__dirname3, "..", "webpack.config.cjs");
|
|
117166
117643
|
}
|
|
117167
|
-
const scriptsPath =
|
|
117644
|
+
const scriptsPath = config.build?.scriptsPath ? this.configManager.resolvePath(config.build.scriptsPath) : undefined;
|
|
117168
117645
|
logger.info(`Scanning blocks in: ${blocksDir}`);
|
|
117169
117646
|
logger.info(`Output directory: ${outputDir}`);
|
|
117170
117647
|
if (scriptsPath) {
|
|
@@ -117211,7 +117688,7 @@ class BuildCommand {
|
|
|
117211
117688
|
if (block.scripts && block.scripts.length > 0) {
|
|
117212
117689
|
const result2 = results.find((r) => r.blockName === block.name);
|
|
117213
117690
|
if (result2?.success) {
|
|
117214
|
-
const scriptPaths = block.scripts.map((script) => `scripts/${
|
|
117691
|
+
const scriptPaths = block.scripts.map((script) => `scripts/${path22.basename(script).replace(/\.ts$/, ".js")}`);
|
|
117215
117692
|
this.blockScripts.set(block.name, scriptPaths);
|
|
117216
117693
|
}
|
|
117217
117694
|
}
|
|
@@ -117225,7 +117702,7 @@ Failed to build ${failures.length} block(s):`);
|
|
|
117225
117702
|
}
|
|
117226
117703
|
}
|
|
117227
117704
|
if (this.blockScripts.size > 0) {
|
|
117228
|
-
const phpPath =
|
|
117705
|
+
const phpPath = path22.join(path22.dirname(outputDir), "functions-blocks-scripts.php");
|
|
117229
117706
|
this.phpGenerator.generateScriptRegistrationPHP(this.blockScripts, phpPath);
|
|
117230
117707
|
}
|
|
117231
117708
|
await this.generateTypeDefinitions(outputDir);
|
|
@@ -117253,7 +117730,7 @@ Failed to build ${failures.length} block(s):`);
|
|
|
117253
117730
|
logger.warn("No blocks found for type generation");
|
|
117254
117731
|
return;
|
|
117255
117732
|
}
|
|
117256
|
-
const typesPath =
|
|
117733
|
+
const typesPath = path22.join(outputDir, "blocks.d.ts");
|
|
117257
117734
|
await this.typeGenerator.generateDefinitions(blocks, typesPath);
|
|
117258
117735
|
logger.success(`✅ Generated TypeScript definitions for ${blocks.length} block(s)`);
|
|
117259
117736
|
} catch (error) {
|
|
@@ -117263,8 +117740,8 @@ Failed to build ${failures.length} block(s):`);
|
|
|
117263
117740
|
}
|
|
117264
117741
|
|
|
117265
117742
|
// src/commands/build-templates-command.ts
|
|
117266
|
-
import * as
|
|
117267
|
-
import * as
|
|
117743
|
+
import * as fs19 from "fs";
|
|
117744
|
+
import * as path23 from "path";
|
|
117268
117745
|
class BuildTemplatesCommand {
|
|
117269
117746
|
configManager;
|
|
117270
117747
|
constructor() {
|
|
@@ -117272,8 +117749,8 @@ class BuildTemplatesCommand {
|
|
|
117272
117749
|
}
|
|
117273
117750
|
async execute(options = {}) {
|
|
117274
117751
|
logger.progress("Starting template build operation...");
|
|
117275
|
-
const
|
|
117276
|
-
const templatesConfig =
|
|
117752
|
+
const config = this.configManager.getConfig();
|
|
117753
|
+
const templatesConfig = config.templates;
|
|
117277
117754
|
if (!templatesConfig) {
|
|
117278
117755
|
logger.error("Templates configuration not found in wordpress-flow.config.json");
|
|
117279
117756
|
logger.info('Add a "templates" section to your config with "templatesDir" and "outputDir"');
|
|
@@ -117281,12 +117758,12 @@ class BuildTemplatesCommand {
|
|
|
117281
117758
|
}
|
|
117282
117759
|
const templatesDir = options.templatesDir || this.configManager.resolvePath(templatesConfig.templatesDir);
|
|
117283
117760
|
const outputDir = options.outputDir || this.configManager.resolvePath(templatesConfig.outputDir);
|
|
117284
|
-
if (!
|
|
117761
|
+
if (!fs19.existsSync(templatesDir)) {
|
|
117285
117762
|
logger.error(`Templates directory not found: ${templatesDir}`);
|
|
117286
117763
|
return;
|
|
117287
117764
|
}
|
|
117288
|
-
|
|
117289
|
-
const buildConfig =
|
|
117765
|
+
fs19.mkdirSync(outputDir, { recursive: true });
|
|
117766
|
+
const buildConfig = config.build;
|
|
117290
117767
|
let blockRegistry;
|
|
117291
117768
|
if (buildConfig) {
|
|
117292
117769
|
const blocksOutputDir = this.configManager.resolvePath(buildConfig.outputDir);
|
|
@@ -117306,8 +117783,8 @@ class BuildTemplatesCommand {
|
|
|
117306
117783
|
let errorCount = 0;
|
|
117307
117784
|
for (let i2 = 0;i2 < templateFiles.length; i2++) {
|
|
117308
117785
|
const templateFile = templateFiles[i2];
|
|
117309
|
-
const relativePath =
|
|
117310
|
-
const templateName =
|
|
117786
|
+
const relativePath = path23.relative(templatesDir, templateFile);
|
|
117787
|
+
const templateName = path23.basename(templateFile, ".mdx");
|
|
117311
117788
|
logger.step(i2 + 1, templateFiles.length, `Building template: ${relativePath}`);
|
|
117312
117789
|
try {
|
|
117313
117790
|
await this.buildTemplate(templateFile, templateName, outputDir, renderer);
|
|
@@ -117327,19 +117804,19 @@ class BuildTemplatesCommand {
|
|
|
117327
117804
|
}
|
|
117328
117805
|
}
|
|
117329
117806
|
async buildTemplate(templatePath, templateName, outputDir, renderer) {
|
|
117330
|
-
const mdxContent =
|
|
117807
|
+
const mdxContent = fs19.readFileSync(templatePath, "utf8");
|
|
117331
117808
|
const cleanContent = this.removeFrontmatter(mdxContent);
|
|
117332
117809
|
const html5 = await renderer.renderMDXToHTML(cleanContent);
|
|
117333
117810
|
const cleanHTML = renderer.postProcessHTML(html5);
|
|
117334
|
-
const outputPath =
|
|
117335
|
-
|
|
117336
|
-
logger.info(`✓ Generated: ${
|
|
117811
|
+
const outputPath = path23.join(outputDir, `${templateName}.html`);
|
|
117812
|
+
fs19.writeFileSync(outputPath, cleanHTML, "utf8");
|
|
117813
|
+
logger.info(`✓ Generated: ${path23.relative(process.cwd(), outputPath)}`);
|
|
117337
117814
|
}
|
|
117338
117815
|
findMDXFiles(dir) {
|
|
117339
117816
|
const files = [];
|
|
117340
|
-
const entries =
|
|
117817
|
+
const entries = fs19.readdirSync(dir, { withFileTypes: true });
|
|
117341
117818
|
for (const entry of entries) {
|
|
117342
|
-
const fullPath =
|
|
117819
|
+
const fullPath = path23.join(dir, entry.name);
|
|
117343
117820
|
if (entry.isDirectory()) {
|
|
117344
117821
|
files.push(...this.findMDXFiles(fullPath));
|
|
117345
117822
|
} else if (entry.isFile() && entry.name.endsWith(".mdx")) {
|
|
@@ -117354,6 +117831,72 @@ class BuildTemplatesCommand {
|
|
|
117354
117831
|
}
|
|
117355
117832
|
}
|
|
117356
117833
|
|
|
117834
|
+
// src/commands/env-command.ts
|
|
117835
|
+
import * as fs20 from "fs";
|
|
117836
|
+
import * as path24 from "path";
|
|
117837
|
+
class EnvCommand {
|
|
117838
|
+
configManager;
|
|
117839
|
+
constructor() {
|
|
117840
|
+
this.configManager = ConfigManager.getInstance();
|
|
117841
|
+
}
|
|
117842
|
+
getDockerEnvManager() {
|
|
117843
|
+
const config = this.configManager.getConfig();
|
|
117844
|
+
if (!config.env) {
|
|
117845
|
+
throw new Error("No Docker environment configured. Add 'env' section to your config file.");
|
|
117846
|
+
}
|
|
117847
|
+
const packageJsonPath = path24.join(this.configManager.getConfigDir(), "package.json");
|
|
117848
|
+
let projectName = "wordpress-project";
|
|
117849
|
+
if (fs20.existsSync(packageJsonPath)) {
|
|
117850
|
+
try {
|
|
117851
|
+
const pkg = JSON.parse(fs20.readFileSync(packageJsonPath, "utf8"));
|
|
117852
|
+
projectName = pkg.name || projectName;
|
|
117853
|
+
} catch {}
|
|
117854
|
+
}
|
|
117855
|
+
return new DockerEnvManager({
|
|
117856
|
+
projectName,
|
|
117857
|
+
workspaceDir: this.configManager.getConfigDir(),
|
|
117858
|
+
config: config.env
|
|
117859
|
+
});
|
|
117860
|
+
}
|
|
117861
|
+
async destroy() {
|
|
117862
|
+
console.log(`
|
|
117863
|
+
\uD83D\uDDD1️ Destroying Docker environment...
|
|
117864
|
+
`);
|
|
117865
|
+
const manager = this.getDockerEnvManager();
|
|
117866
|
+
await manager.cleanup();
|
|
117867
|
+
console.log(`
|
|
117868
|
+
✅ Docker environment destroyed
|
|
117869
|
+
`);
|
|
117870
|
+
}
|
|
117871
|
+
async dbImport(filePath2) {
|
|
117872
|
+
const config = this.configManager.getConfig();
|
|
117873
|
+
const inputPath = filePath2 || config.env?.sqlDump;
|
|
117874
|
+
if (!inputPath) {
|
|
117875
|
+
throw new Error("No SQL file specified. Use --file option or set 'sqlDump' in config.");
|
|
117876
|
+
}
|
|
117877
|
+
console.log(`
|
|
117878
|
+
\uD83D\uDCE5 Importing database from ${inputPath}...
|
|
117879
|
+
`);
|
|
117880
|
+
const manager = this.getDockerEnvManager();
|
|
117881
|
+
await manager.importSqlDumpFromFile(inputPath);
|
|
117882
|
+
console.log(`
|
|
117883
|
+
✅ Database imported successfully
|
|
117884
|
+
`);
|
|
117885
|
+
}
|
|
117886
|
+
async dbExport(filePath2) {
|
|
117887
|
+
const config = this.configManager.getConfig();
|
|
117888
|
+
const outputPath = filePath2 || config.env?.sqlDump || "./db/dump.sql";
|
|
117889
|
+
console.log(`
|
|
117890
|
+
\uD83D\uDCE4 Exporting database to ${outputPath}...
|
|
117891
|
+
`);
|
|
117892
|
+
const manager = this.getDockerEnvManager();
|
|
117893
|
+
await manager.exportSqlDump(outputPath);
|
|
117894
|
+
console.log(`
|
|
117895
|
+
✅ Database exported successfully
|
|
117896
|
+
`);
|
|
117897
|
+
}
|
|
117898
|
+
}
|
|
117899
|
+
|
|
117357
117900
|
// src/index.ts
|
|
117358
117901
|
var program2 = new Command;
|
|
117359
117902
|
program2.name("wordpress-flow").description("Build WordPress sites with React, TypeScript, and MDX - A content-first development framework").version(package_default.version);
|
|
@@ -117438,7 +117981,7 @@ program2.command("build-templates").description("Build WordPress theme templates
|
|
|
117438
117981
|
process.exit(1);
|
|
117439
117982
|
}
|
|
117440
117983
|
});
|
|
117441
|
-
program2.command("dev").description("Unified development mode - watches blocks, templates, and pages with optimized rebuilds").option("--fresh", "Force full rebuild, ignore cached hashes").option("--debounce <ms>", "Change batching window in milliseconds (default: 300)", "300").option("-c, --concurrency <number>", "Number of parallel workers (default: CPU cores - 1)").option("--no-push", "Disable auto-push to WordPress").option("--no-templates", "Disable template rebuilding").option("-v, --verbose", "Enable verbose output").action(async (options) => {
|
|
117984
|
+
program2.command("dev").description("Unified development mode - watches blocks, templates, and pages with optimized rebuilds").option("--fresh", "Force full rebuild, ignore cached hashes").option("--debounce <ms>", "Change batching window in milliseconds (default: 300)", "300").option("-c, --concurrency <number>", "Number of parallel workers (default: CPU cores - 1)").option("--no-push", "Disable auto-push to WordPress").option("--no-templates", "Disable template rebuilding").option("--skip-env", "Skip Docker environment setup").option("-v, --verbose", "Enable verbose output").action(async (options) => {
|
|
117442
117985
|
try {
|
|
117443
117986
|
await ensureConfiguration();
|
|
117444
117987
|
const command = new DevCommand;
|
|
@@ -117448,6 +117991,7 @@ program2.command("dev").description("Unified development mode - watches blocks,
|
|
|
117448
117991
|
concurrency: options.concurrency ? parseInt(options.concurrency, 10) : undefined,
|
|
117449
117992
|
push: options.push !== false,
|
|
117450
117993
|
templates: options.templates !== false,
|
|
117994
|
+
skipEnv: options.skipEnv || false,
|
|
117451
117995
|
verbose: options.verbose || false
|
|
117452
117996
|
});
|
|
117453
117997
|
} catch (error) {
|
|
@@ -117455,6 +117999,36 @@ program2.command("dev").description("Unified development mode - watches blocks,
|
|
|
117455
117999
|
process.exit(1);
|
|
117456
118000
|
}
|
|
117457
118001
|
});
|
|
118002
|
+
program2.command("destroy").description("Remove Docker containers and volumes for this project").action(async () => {
|
|
118003
|
+
try {
|
|
118004
|
+
await ensureConfiguration();
|
|
118005
|
+
const command = new EnvCommand;
|
|
118006
|
+
await command.destroy();
|
|
118007
|
+
} catch (error) {
|
|
118008
|
+
logger.error("Destroy command failed:", error);
|
|
118009
|
+
process.exit(1);
|
|
118010
|
+
}
|
|
118011
|
+
});
|
|
118012
|
+
program2.command("database import").description("Import SQL dump into Docker database").option("-f, --file <path>", "Path to SQL file (defaults to config sqlDump)").action(async (options) => {
|
|
118013
|
+
try {
|
|
118014
|
+
await ensureConfiguration();
|
|
118015
|
+
const command = new EnvCommand;
|
|
118016
|
+
await command.dbImport(options.file);
|
|
118017
|
+
} catch (error) {
|
|
118018
|
+
logger.error("Database import failed:", error);
|
|
118019
|
+
process.exit(1);
|
|
118020
|
+
}
|
|
118021
|
+
});
|
|
118022
|
+
program2.command("database export").description("Export Docker database to SQL file").option("-f, --file <path>", "Output path for SQL file (defaults to config sqlDump or ./db/dump.sql)").action(async (options) => {
|
|
118023
|
+
try {
|
|
118024
|
+
await ensureConfiguration();
|
|
118025
|
+
const command = new EnvCommand;
|
|
118026
|
+
await command.dbExport(options.file);
|
|
118027
|
+
} catch (error) {
|
|
118028
|
+
logger.error("Database export failed:", error);
|
|
118029
|
+
process.exit(1);
|
|
118030
|
+
}
|
|
118031
|
+
});
|
|
117458
118032
|
async function ensureConfiguration() {
|
|
117459
118033
|
const configManager = ConfigManager.getInstance();
|
|
117460
118034
|
if (!configManager.hasConfig()) {
|