@wordpress-flow/cli 1.1.3 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build/block-build-worker.js +1 -1
- package/dist/index.js +1705 -1052
- 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,21 +80895,65 @@ 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";
|
|
80900
|
+
var DEFAULTS = {
|
|
80901
|
+
paths: {
|
|
80902
|
+
theme: "./theme",
|
|
80903
|
+
content: "./content",
|
|
80904
|
+
plugins: "./plugins"
|
|
80905
|
+
},
|
|
80906
|
+
sync: {
|
|
80907
|
+
excludePostTypes: [],
|
|
80908
|
+
includedPostStatuses: ["publish", "draft"]
|
|
80909
|
+
},
|
|
80910
|
+
dev: {
|
|
80911
|
+
port: 8888,
|
|
80912
|
+
databasePort: 3306,
|
|
80913
|
+
phpVersion: "8.2",
|
|
80914
|
+
wordpressVersion: "latest",
|
|
80915
|
+
plugins: []
|
|
80916
|
+
}
|
|
80917
|
+
};
|
|
81296
80918
|
|
|
81297
80919
|
class ConfigManager {
|
|
81298
80920
|
static instance;
|
|
81299
80921
|
config = null;
|
|
80922
|
+
rawConfig = null;
|
|
81300
80923
|
configPath;
|
|
81301
80924
|
configDir;
|
|
81302
80925
|
envPath;
|
|
80926
|
+
runtimeDatabase = null;
|
|
81303
80927
|
constructor() {
|
|
81304
80928
|
this.configPath = path2.join(process.cwd(), "wordpress-flow.config.json");
|
|
81305
80929
|
this.configDir = path2.dirname(this.configPath);
|
|
81306
80930
|
this.envPath = path2.join(this.configDir, ".env");
|
|
81307
|
-
|
|
80931
|
+
this.loadEnvFile();
|
|
80932
|
+
}
|
|
80933
|
+
loadEnvFile() {
|
|
80934
|
+
if (!fs2.existsSync(this.envPath))
|
|
80935
|
+
return;
|
|
80936
|
+
try {
|
|
80937
|
+
const content2 = fs2.readFileSync(this.envPath, "utf8");
|
|
80938
|
+
const lines = content2.split(`
|
|
80939
|
+
`);
|
|
80940
|
+
for (const line of lines) {
|
|
80941
|
+
const trimmed = line.trim();
|
|
80942
|
+
if (!trimmed || trimmed.startsWith("#"))
|
|
80943
|
+
continue;
|
|
80944
|
+
const eqIndex = trimmed.indexOf("=");
|
|
80945
|
+
if (eqIndex === -1)
|
|
80946
|
+
continue;
|
|
80947
|
+
const key = trimmed.slice(0, eqIndex).trim();
|
|
80948
|
+
let value = trimmed.slice(eqIndex + 1).trim();
|
|
80949
|
+
if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
|
|
80950
|
+
value = value.slice(1, -1);
|
|
80951
|
+
}
|
|
80952
|
+
if (process.env[key] === undefined) {
|
|
80953
|
+
process.env[key] = value;
|
|
80954
|
+
}
|
|
80955
|
+
}
|
|
80956
|
+
} catch {}
|
|
81308
80957
|
}
|
|
81309
80958
|
static getInstance() {
|
|
81310
80959
|
if (!ConfigManager.instance) {
|
|
@@ -81316,24 +80965,144 @@ class ConfigManager {
|
|
|
81316
80965
|
if (this.config) {
|
|
81317
80966
|
return this.config;
|
|
81318
80967
|
}
|
|
81319
|
-
|
|
81320
|
-
|
|
80968
|
+
let rawConfig = {};
|
|
80969
|
+
if (fs2.existsSync(this.configPath)) {
|
|
80970
|
+
try {
|
|
80971
|
+
const configContent = fs2.readFileSync(this.configPath, "utf8");
|
|
80972
|
+
rawConfig = JSON.parse(configContent);
|
|
80973
|
+
if (this.isLegacyConfig(rawConfig)) {
|
|
80974
|
+
rawConfig = this.migrateLegacyConfig(rawConfig);
|
|
80975
|
+
}
|
|
80976
|
+
} catch (error) {
|
|
80977
|
+
throw new Error(`Failed to load configuration: ${error.message}`);
|
|
80978
|
+
}
|
|
81321
80979
|
}
|
|
81322
|
-
|
|
81323
|
-
|
|
81324
|
-
|
|
81325
|
-
|
|
81326
|
-
|
|
81327
|
-
|
|
81328
|
-
|
|
80980
|
+
this.rawConfig = rawConfig;
|
|
80981
|
+
this.config = this.resolveConfig(rawConfig);
|
|
80982
|
+
return this.config;
|
|
80983
|
+
}
|
|
80984
|
+
isLegacyConfig(config) {
|
|
80985
|
+
return config.wordpress !== undefined || config.env !== undefined || config.build !== undefined;
|
|
80986
|
+
}
|
|
80987
|
+
migrateLegacyConfig(legacy) {
|
|
80988
|
+
const newConfig = {};
|
|
80989
|
+
if (legacy.env?.themeDir || legacy.paths?.mdxOutputDir || legacy.env?.pluginsDir) {
|
|
80990
|
+
newConfig.paths = {
|
|
80991
|
+
theme: legacy.env?.themeDir || legacy.build?.blocksDir?.replace("/blocks", "") || DEFAULTS.paths.theme,
|
|
80992
|
+
content: legacy.paths?.mdxOutputDir || DEFAULTS.paths.content,
|
|
80993
|
+
plugins: legacy.env?.pluginsDir || DEFAULTS.paths.plugins
|
|
80994
|
+
};
|
|
80995
|
+
}
|
|
80996
|
+
if (legacy.sync?.excludePostTypes || legacy.sync?.includedPostStatuses) {
|
|
80997
|
+
newConfig.sync = {
|
|
80998
|
+
excludePostTypes: legacy.sync?.excludePostTypes,
|
|
80999
|
+
includedPostStatuses: legacy.sync?.includedPostStatuses
|
|
81000
|
+
};
|
|
81001
|
+
}
|
|
81002
|
+
if (legacy.env) {
|
|
81003
|
+
newConfig.dev = {
|
|
81004
|
+
port: legacy.env.port,
|
|
81005
|
+
databasePort: legacy.env.databasePort,
|
|
81006
|
+
phpVersion: legacy.env.phpVersion,
|
|
81007
|
+
wordpressVersion: legacy.env.wordpressVersion,
|
|
81008
|
+
plugins: legacy.env.plugins,
|
|
81009
|
+
sqlDump: legacy.env.sqlDump
|
|
81010
|
+
};
|
|
81329
81011
|
}
|
|
81012
|
+
return newConfig;
|
|
81013
|
+
}
|
|
81014
|
+
resolveConfig(raw) {
|
|
81015
|
+
const theme = raw.paths?.theme || DEFAULTS.paths.theme;
|
|
81016
|
+
const content2 = raw.paths?.content || DEFAULTS.paths.content;
|
|
81017
|
+
const plugins = raw.paths?.plugins || DEFAULTS.paths.plugins;
|
|
81018
|
+
return {
|
|
81019
|
+
paths: {
|
|
81020
|
+
theme,
|
|
81021
|
+
content: content2,
|
|
81022
|
+
plugins,
|
|
81023
|
+
blocks: `${theme}/blocks`,
|
|
81024
|
+
dist: `${theme}/dist`,
|
|
81025
|
+
scripts: `${theme}/scripts`,
|
|
81026
|
+
templates: `${content2}/templates`,
|
|
81027
|
+
templateParts: `${content2}/parts`,
|
|
81028
|
+
templatesOutput: `${theme}/templates`,
|
|
81029
|
+
partsOutput: `${theme}/parts`
|
|
81030
|
+
},
|
|
81031
|
+
sync: {
|
|
81032
|
+
excludePostTypes: raw.sync?.excludePostTypes || DEFAULTS.sync.excludePostTypes,
|
|
81033
|
+
includedPostStatuses: raw.sync?.includedPostStatuses || DEFAULTS.sync.includedPostStatuses
|
|
81034
|
+
},
|
|
81035
|
+
dev: {
|
|
81036
|
+
port: raw.dev?.port || DEFAULTS.dev.port,
|
|
81037
|
+
databasePort: raw.dev?.databasePort || DEFAULTS.dev.databasePort,
|
|
81038
|
+
phpVersion: raw.dev?.phpVersion || DEFAULTS.dev.phpVersion,
|
|
81039
|
+
wordpressVersion: raw.dev?.wordpressVersion || DEFAULTS.dev.wordpressVersion,
|
|
81040
|
+
plugins: raw.dev?.plugins || DEFAULTS.dev.plugins,
|
|
81041
|
+
sqlDump: raw.dev?.sqlDump
|
|
81042
|
+
},
|
|
81043
|
+
database: this.runtimeDatabase || undefined
|
|
81044
|
+
};
|
|
81330
81045
|
}
|
|
81331
|
-
async saveConfig(
|
|
81332
|
-
const
|
|
81333
|
-
|
|
81334
|
-
|
|
81335
|
-
|
|
81336
|
-
|
|
81046
|
+
async saveConfig(config) {
|
|
81047
|
+
const minimalConfig = this.stripDefaults(config);
|
|
81048
|
+
fs2.writeFileSync(this.configPath, JSON.stringify(minimalConfig, null, 2));
|
|
81049
|
+
this.rawConfig = config;
|
|
81050
|
+
this.config = this.resolveConfig(config);
|
|
81051
|
+
}
|
|
81052
|
+
stripDefaults(config) {
|
|
81053
|
+
const result2 = {};
|
|
81054
|
+
if (config.paths) {
|
|
81055
|
+
const paths = {};
|
|
81056
|
+
if (config.paths.theme && config.paths.theme !== DEFAULTS.paths.theme) {
|
|
81057
|
+
paths.theme = config.paths.theme;
|
|
81058
|
+
}
|
|
81059
|
+
if (config.paths.content && config.paths.content !== DEFAULTS.paths.content) {
|
|
81060
|
+
paths.content = config.paths.content;
|
|
81061
|
+
}
|
|
81062
|
+
if (config.paths.plugins && config.paths.plugins !== DEFAULTS.paths.plugins) {
|
|
81063
|
+
paths.plugins = config.paths.plugins;
|
|
81064
|
+
}
|
|
81065
|
+
if (Object.keys(paths).length > 0) {
|
|
81066
|
+
result2.paths = paths;
|
|
81067
|
+
}
|
|
81068
|
+
}
|
|
81069
|
+
if (config.sync) {
|
|
81070
|
+
const sync = {};
|
|
81071
|
+
if (config.sync.excludePostTypes && config.sync.excludePostTypes.length > 0) {
|
|
81072
|
+
sync.excludePostTypes = config.sync.excludePostTypes;
|
|
81073
|
+
}
|
|
81074
|
+
if (config.sync.includedPostStatuses && JSON.stringify(config.sync.includedPostStatuses) !== JSON.stringify(DEFAULTS.sync.includedPostStatuses)) {
|
|
81075
|
+
sync.includedPostStatuses = config.sync.includedPostStatuses;
|
|
81076
|
+
}
|
|
81077
|
+
if (Object.keys(sync).length > 0) {
|
|
81078
|
+
result2.sync = sync;
|
|
81079
|
+
}
|
|
81080
|
+
}
|
|
81081
|
+
if (config.dev) {
|
|
81082
|
+
const dev = {};
|
|
81083
|
+
if (config.dev.port && config.dev.port !== DEFAULTS.dev.port) {
|
|
81084
|
+
dev.port = config.dev.port;
|
|
81085
|
+
}
|
|
81086
|
+
if (config.dev.databasePort && config.dev.databasePort !== DEFAULTS.dev.databasePort) {
|
|
81087
|
+
dev.databasePort = config.dev.databasePort;
|
|
81088
|
+
}
|
|
81089
|
+
if (config.dev.phpVersion && config.dev.phpVersion !== DEFAULTS.dev.phpVersion) {
|
|
81090
|
+
dev.phpVersion = config.dev.phpVersion;
|
|
81091
|
+
}
|
|
81092
|
+
if (config.dev.wordpressVersion && config.dev.wordpressVersion !== DEFAULTS.dev.wordpressVersion) {
|
|
81093
|
+
dev.wordpressVersion = config.dev.wordpressVersion;
|
|
81094
|
+
}
|
|
81095
|
+
if (config.dev.plugins && config.dev.plugins.length > 0) {
|
|
81096
|
+
dev.plugins = config.dev.plugins;
|
|
81097
|
+
}
|
|
81098
|
+
if (config.dev.sqlDump) {
|
|
81099
|
+
dev.sqlDump = config.dev.sqlDump;
|
|
81100
|
+
}
|
|
81101
|
+
if (Object.keys(dev).length > 0) {
|
|
81102
|
+
result2.dev = dev;
|
|
81103
|
+
}
|
|
81104
|
+
}
|
|
81105
|
+
return result2;
|
|
81337
81106
|
}
|
|
81338
81107
|
getConfig() {
|
|
81339
81108
|
if (!this.config) {
|
|
@@ -81344,11 +81113,18 @@ class ConfigManager {
|
|
|
81344
81113
|
hasConfig() {
|
|
81345
81114
|
return fs2.existsSync(this.configPath);
|
|
81346
81115
|
}
|
|
81347
|
-
|
|
81348
|
-
|
|
81116
|
+
setDatabaseConnection(connection) {
|
|
81117
|
+
this.runtimeDatabase = connection;
|
|
81118
|
+
if (this.config) {
|
|
81119
|
+
this.config.database = connection;
|
|
81120
|
+
}
|
|
81349
81121
|
}
|
|
81350
|
-
|
|
81351
|
-
return this.
|
|
81122
|
+
getDatabaseConnection() {
|
|
81123
|
+
return this.config?.database;
|
|
81124
|
+
}
|
|
81125
|
+
getWordPressUrl() {
|
|
81126
|
+
const port = this.config?.dev.port || DEFAULTS.dev.port;
|
|
81127
|
+
return `http://localhost:${port}`;
|
|
81352
81128
|
}
|
|
81353
81129
|
resolvePath(relativePath) {
|
|
81354
81130
|
if (path2.isAbsolute(relativePath)) {
|
|
@@ -81359,60 +81135,70 @@ class ConfigManager {
|
|
|
81359
81135
|
getConfigDir() {
|
|
81360
81136
|
return this.configDir;
|
|
81361
81137
|
}
|
|
81362
|
-
|
|
81363
|
-
const
|
|
81364
|
-
|
|
81365
|
-
|
|
81366
|
-
|
|
81367
|
-
|
|
81368
|
-
|
|
81369
|
-
|
|
81370
|
-
|
|
81371
|
-
|
|
81372
|
-
|
|
81138
|
+
getLegacyConfig() {
|
|
81139
|
+
const config = this.getConfig();
|
|
81140
|
+
const dbConnection = config.database || {
|
|
81141
|
+
host: "127.0.0.1",
|
|
81142
|
+
port: config.dev.databasePort,
|
|
81143
|
+
database: "wordpress",
|
|
81144
|
+
username: "wordpress",
|
|
81145
|
+
password: "wordpress"
|
|
81146
|
+
};
|
|
81147
|
+
return {
|
|
81148
|
+
wordpress: {
|
|
81149
|
+
type: "database",
|
|
81150
|
+
wordpressUrl: this.getWordPressUrl(),
|
|
81151
|
+
syncPath: config.paths.content,
|
|
81152
|
+
postTypes: ["post", "page"],
|
|
81153
|
+
database: dbConnection
|
|
81154
|
+
},
|
|
81155
|
+
paths: {
|
|
81156
|
+
mdxOutputDir: config.paths.content,
|
|
81157
|
+
postTypeMappings: {
|
|
81158
|
+
post: `${config.paths.content}/post`,
|
|
81159
|
+
page: `${config.paths.content}/page`
|
|
81160
|
+
}
|
|
81161
|
+
},
|
|
81162
|
+
sync: {
|
|
81163
|
+
watchForChanges: true,
|
|
81164
|
+
conflictResolution: "manual",
|
|
81165
|
+
excludePostTypes: config.sync.excludePostTypes,
|
|
81166
|
+
includedPostStatuses: config.sync.includedPostStatuses
|
|
81167
|
+
},
|
|
81168
|
+
build: {
|
|
81169
|
+
blocksDir: config.paths.blocks,
|
|
81170
|
+
outputDir: config.paths.dist,
|
|
81171
|
+
scriptsPath: config.paths.scripts
|
|
81172
|
+
},
|
|
81173
|
+
templates: {
|
|
81174
|
+
templatesDir: config.paths.templates,
|
|
81175
|
+
outputDir: config.paths.templatesOutput
|
|
81176
|
+
},
|
|
81177
|
+
templateParts: {
|
|
81178
|
+
partsDir: config.paths.templateParts,
|
|
81179
|
+
outputDir: config.paths.partsOutput
|
|
81180
|
+
},
|
|
81181
|
+
env: {
|
|
81182
|
+
port: config.dev.port,
|
|
81183
|
+
databasePort: config.dev.databasePort,
|
|
81184
|
+
phpVersion: config.dev.phpVersion,
|
|
81185
|
+
wordpressVersion: config.dev.wordpressVersion,
|
|
81186
|
+
themeDir: config.paths.theme,
|
|
81187
|
+
pluginsDir: config.paths.plugins,
|
|
81188
|
+
plugins: config.dev.plugins,
|
|
81189
|
+
sqlDump: config.dev.sqlDump,
|
|
81190
|
+
volumes: {
|
|
81191
|
+
database: true,
|
|
81192
|
+
uploads: true
|
|
81193
|
+
}
|
|
81373
81194
|
}
|
|
81374
|
-
}
|
|
81375
|
-
return mergedConfig;
|
|
81376
|
-
}
|
|
81377
|
-
stripSensitiveData(config2) {
|
|
81378
|
-
const strippedConfig = JSON.parse(JSON.stringify(config2));
|
|
81379
|
-
if (strippedConfig.wordpress.type === "rest-api") {
|
|
81380
|
-
delete strippedConfig.wordpress.applicationPassword;
|
|
81381
|
-
} else if (strippedConfig.wordpress.type === "database") {
|
|
81382
|
-
delete strippedConfig.wordpress.database.password;
|
|
81383
|
-
}
|
|
81384
|
-
return strippedConfig;
|
|
81195
|
+
};
|
|
81385
81196
|
}
|
|
81386
|
-
|
|
81387
|
-
|
|
81388
|
-
if (config2.wordpress.type === "rest-api") {
|
|
81389
|
-
envVars.WP_APPLICATION_PASSWORD = config2.wordpress.applicationPassword;
|
|
81390
|
-
} else if (config2.wordpress.type === "database") {
|
|
81391
|
-
envVars.DB_PASSWORD = config2.wordpress.database.password;
|
|
81392
|
-
}
|
|
81393
|
-
return envVars;
|
|
81197
|
+
getWordPressConfig() {
|
|
81198
|
+
return this.getLegacyConfig().wordpress;
|
|
81394
81199
|
}
|
|
81395
|
-
|
|
81396
|
-
|
|
81397
|
-
if (fs2.existsSync(this.envPath)) {
|
|
81398
|
-
envContent = fs2.readFileSync(this.envPath, "utf8");
|
|
81399
|
-
}
|
|
81400
|
-
const existingVars = {};
|
|
81401
|
-
envContent.split(`
|
|
81402
|
-
`).forEach((line) => {
|
|
81403
|
-
const trimmed = line.trim();
|
|
81404
|
-
if (trimmed && !trimmed.startsWith("#")) {
|
|
81405
|
-
const [key, ...valueParts] = trimmed.split("=");
|
|
81406
|
-
if (key && valueParts.length > 0) {
|
|
81407
|
-
existingVars[key.trim()] = valueParts.join("=");
|
|
81408
|
-
}
|
|
81409
|
-
}
|
|
81410
|
-
});
|
|
81411
|
-
const mergedVars = { ...existingVars, ...newVars };
|
|
81412
|
-
const newEnvContent = Object.entries(mergedVars).map(([key, value]) => `${key}=${value}`).join(`
|
|
81413
|
-
`) + `
|
|
81414
|
-
`;
|
|
81415
|
-
fs2.writeFileSync(this.envPath, newEnvContent);
|
|
81200
|
+
getSyncPaths() {
|
|
81201
|
+
return this.getLegacyConfig().paths;
|
|
81416
81202
|
}
|
|
81417
81203
|
}
|
|
81418
81204
|
// src/config/logger.ts
|
|
@@ -81865,7 +81651,7 @@ var utils_default = {
|
|
|
81865
81651
|
};
|
|
81866
81652
|
|
|
81867
81653
|
// ../../node_modules/axios/lib/core/AxiosError.js
|
|
81868
|
-
function AxiosError(message, code,
|
|
81654
|
+
function AxiosError(message, code, config, request, response) {
|
|
81869
81655
|
Error.call(this);
|
|
81870
81656
|
if (Error.captureStackTrace) {
|
|
81871
81657
|
Error.captureStackTrace(this, this.constructor);
|
|
@@ -81875,7 +81661,7 @@ function AxiosError(message, code, config2, request, response) {
|
|
|
81875
81661
|
this.message = message;
|
|
81876
81662
|
this.name = "AxiosError";
|
|
81877
81663
|
code && (this.code = code);
|
|
81878
|
-
|
|
81664
|
+
config && (this.config = config);
|
|
81879
81665
|
request && (this.request = request);
|
|
81880
81666
|
if (response) {
|
|
81881
81667
|
this.response = response;
|
|
@@ -81919,7 +81705,7 @@ var descriptors = {};
|
|
|
81919
81705
|
});
|
|
81920
81706
|
Object.defineProperties(AxiosError, descriptors);
|
|
81921
81707
|
Object.defineProperty(prototype, "isAxiosError", { value: true });
|
|
81922
|
-
AxiosError.from = (error, code,
|
|
81708
|
+
AxiosError.from = (error, code, config, request, response, customProps) => {
|
|
81923
81709
|
const axiosError = Object.create(prototype);
|
|
81924
81710
|
utils_default.toFlatObject(error, axiosError, function filter(obj) {
|
|
81925
81711
|
return obj !== Error.prototype;
|
|
@@ -81928,7 +81714,7 @@ AxiosError.from = (error, code, config2, request, response, customProps) => {
|
|
|
81928
81714
|
});
|
|
81929
81715
|
const msg = error && error.message ? error.message : "Error";
|
|
81930
81716
|
const errCode = code == null && error ? error.code : code;
|
|
81931
|
-
AxiosError.call(axiosError, msg, errCode,
|
|
81717
|
+
AxiosError.call(axiosError, msg, errCode, config, request, response);
|
|
81932
81718
|
if (error && axiosError.cause == null) {
|
|
81933
81719
|
Object.defineProperty(axiosError, "cause", { value: error, configurable: true });
|
|
81934
81720
|
}
|
|
@@ -82664,12 +82450,12 @@ var AxiosHeaders_default = AxiosHeaders;
|
|
|
82664
82450
|
|
|
82665
82451
|
// ../../node_modules/axios/lib/core/transformData.js
|
|
82666
82452
|
function transformData(fns, response) {
|
|
82667
|
-
const
|
|
82668
|
-
const context = response ||
|
|
82453
|
+
const config = this || defaults_default;
|
|
82454
|
+
const context = response || config;
|
|
82669
82455
|
const headers = AxiosHeaders_default.from(context.headers);
|
|
82670
82456
|
let data = context.data;
|
|
82671
82457
|
utils_default.forEach(fns, function transform(fn) {
|
|
82672
|
-
data = fn.call(
|
|
82458
|
+
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
|
82673
82459
|
});
|
|
82674
82460
|
headers.normalize();
|
|
82675
82461
|
return data;
|
|
@@ -82681,8 +82467,8 @@ function isCancel(value) {
|
|
|
82681
82467
|
}
|
|
82682
82468
|
|
|
82683
82469
|
// ../../node_modules/axios/lib/cancel/CanceledError.js
|
|
82684
|
-
function CanceledError(message,
|
|
82685
|
-
AxiosError_default.call(this, message == null ? "canceled" : message, AxiosError_default.ERR_CANCELED,
|
|
82470
|
+
function CanceledError(message, config, request) {
|
|
82471
|
+
AxiosError_default.call(this, message == null ? "canceled" : message, AxiosError_default.ERR_CANCELED, config, request);
|
|
82686
82472
|
this.name = "CanceledError";
|
|
82687
82473
|
}
|
|
82688
82474
|
utils_default.inherits(CanceledError, AxiosError_default, {
|
|
@@ -83379,17 +83165,17 @@ var http2Transport = {
|
|
|
83379
83165
|
return req;
|
|
83380
83166
|
}
|
|
83381
83167
|
};
|
|
83382
|
-
var http_default = isHttpAdapterSupported && function httpAdapter(
|
|
83168
|
+
var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
83383
83169
|
return wrapAsync(async function dispatchHttpRequest(resolve3, reject, onDone) {
|
|
83384
|
-
let { data, lookup, family, httpVersion = 1, http2Options } =
|
|
83385
|
-
const { responseType, responseEncoding } =
|
|
83386
|
-
const method =
|
|
83170
|
+
let { data, lookup, family, httpVersion = 1, http2Options } = config;
|
|
83171
|
+
const { responseType, responseEncoding } = config;
|
|
83172
|
+
const method = config.method.toUpperCase();
|
|
83387
83173
|
let isDone;
|
|
83388
83174
|
let rejected = false;
|
|
83389
83175
|
let req;
|
|
83390
83176
|
httpVersion = +httpVersion;
|
|
83391
83177
|
if (Number.isNaN(httpVersion)) {
|
|
83392
|
-
throw TypeError(`Invalid protocol version: '${
|
|
83178
|
+
throw TypeError(`Invalid protocol version: '${config.httpVersion}' is not a number`);
|
|
83393
83179
|
}
|
|
83394
83180
|
if (httpVersion !== 1 && httpVersion !== 2) {
|
|
83395
83181
|
throw TypeError(`Unsupported protocol version '${httpVersion}'`);
|
|
@@ -83410,25 +83196,25 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
|
83410
83196
|
const abortEmitter = new EventEmitter;
|
|
83411
83197
|
function abort(reason) {
|
|
83412
83198
|
try {
|
|
83413
|
-
abortEmitter.emit("abort", !reason || reason.type ? new CanceledError_default(null,
|
|
83199
|
+
abortEmitter.emit("abort", !reason || reason.type ? new CanceledError_default(null, config, req) : reason);
|
|
83414
83200
|
} catch (err) {
|
|
83415
83201
|
console.warn("emit error", err);
|
|
83416
83202
|
}
|
|
83417
83203
|
}
|
|
83418
83204
|
abortEmitter.once("abort", reject);
|
|
83419
83205
|
const onFinished = () => {
|
|
83420
|
-
if (
|
|
83421
|
-
|
|
83206
|
+
if (config.cancelToken) {
|
|
83207
|
+
config.cancelToken.unsubscribe(abort);
|
|
83422
83208
|
}
|
|
83423
|
-
if (
|
|
83424
|
-
|
|
83209
|
+
if (config.signal) {
|
|
83210
|
+
config.signal.removeEventListener("abort", abort);
|
|
83425
83211
|
}
|
|
83426
83212
|
abortEmitter.removeAllListeners();
|
|
83427
83213
|
};
|
|
83428
|
-
if (
|
|
83429
|
-
|
|
83430
|
-
if (
|
|
83431
|
-
|
|
83214
|
+
if (config.cancelToken || config.signal) {
|
|
83215
|
+
config.cancelToken && config.cancelToken.subscribe(abort);
|
|
83216
|
+
if (config.signal) {
|
|
83217
|
+
config.signal.aborted ? abort() : config.signal.addEventListener("abort", abort);
|
|
83432
83218
|
}
|
|
83433
83219
|
}
|
|
83434
83220
|
onDone((response, isRejected) => {
|
|
@@ -83448,15 +83234,15 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
|
83448
83234
|
onFinished();
|
|
83449
83235
|
}
|
|
83450
83236
|
});
|
|
83451
|
-
const fullPath = buildFullPath(
|
|
83237
|
+
const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
|
|
83452
83238
|
const parsed = new URL(fullPath, platform_default.hasBrowserEnv ? platform_default.origin : undefined);
|
|
83453
83239
|
const protocol = parsed.protocol || supportedProtocols[0];
|
|
83454
83240
|
if (protocol === "data:") {
|
|
83455
|
-
if (
|
|
83456
|
-
const dataUrl = String(
|
|
83241
|
+
if (config.maxContentLength > -1) {
|
|
83242
|
+
const dataUrl = String(config.url || fullPath || "");
|
|
83457
83243
|
const estimated = estimateDataURLDecodedBytes(dataUrl);
|
|
83458
|
-
if (estimated >
|
|
83459
|
-
return reject(new AxiosError_default("maxContentLength size of " +
|
|
83244
|
+
if (estimated > config.maxContentLength) {
|
|
83245
|
+
return reject(new AxiosError_default("maxContentLength size of " + config.maxContentLength + " exceeded", AxiosError_default.ERR_BAD_RESPONSE, config));
|
|
83460
83246
|
}
|
|
83461
83247
|
}
|
|
83462
83248
|
let convertedData;
|
|
@@ -83465,15 +83251,15 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
|
83465
83251
|
status: 405,
|
|
83466
83252
|
statusText: "method not allowed",
|
|
83467
83253
|
headers: {},
|
|
83468
|
-
config
|
|
83254
|
+
config
|
|
83469
83255
|
});
|
|
83470
83256
|
}
|
|
83471
83257
|
try {
|
|
83472
|
-
convertedData = fromDataURI(
|
|
83473
|
-
Blob:
|
|
83258
|
+
convertedData = fromDataURI(config.url, responseType === "blob", {
|
|
83259
|
+
Blob: config.env && config.env.Blob
|
|
83474
83260
|
});
|
|
83475
83261
|
} catch (err) {
|
|
83476
|
-
throw AxiosError_default.from(err, AxiosError_default.ERR_BAD_REQUEST,
|
|
83262
|
+
throw AxiosError_default.from(err, AxiosError_default.ERR_BAD_REQUEST, config);
|
|
83477
83263
|
}
|
|
83478
83264
|
if (responseType === "text") {
|
|
83479
83265
|
convertedData = convertedData.toString(responseEncoding);
|
|
@@ -83488,16 +83274,16 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
|
83488
83274
|
status: 200,
|
|
83489
83275
|
statusText: "OK",
|
|
83490
83276
|
headers: new AxiosHeaders_default,
|
|
83491
|
-
config
|
|
83277
|
+
config
|
|
83492
83278
|
});
|
|
83493
83279
|
}
|
|
83494
83280
|
if (supportedProtocols.indexOf(protocol) === -1) {
|
|
83495
|
-
return reject(new AxiosError_default("Unsupported protocol " + protocol, AxiosError_default.ERR_BAD_REQUEST,
|
|
83281
|
+
return reject(new AxiosError_default("Unsupported protocol " + protocol, AxiosError_default.ERR_BAD_REQUEST, config));
|
|
83496
83282
|
}
|
|
83497
|
-
const headers = AxiosHeaders_default.from(
|
|
83283
|
+
const headers = AxiosHeaders_default.from(config.headers).normalize();
|
|
83498
83284
|
headers.set("User-Agent", "axios/" + VERSION, false);
|
|
83499
|
-
const { onUploadProgress, onDownloadProgress } =
|
|
83500
|
-
const maxRate =
|
|
83285
|
+
const { onUploadProgress, onDownloadProgress } = config;
|
|
83286
|
+
const maxRate = config.maxRate;
|
|
83501
83287
|
let maxUploadRate = undefined;
|
|
83502
83288
|
let maxDownloadRate = undefined;
|
|
83503
83289
|
if (utils_default.isSpecCompliantForm(data)) {
|
|
@@ -83526,11 +83312,11 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
|
83526
83312
|
} else if (utils_default.isString(data)) {
|
|
83527
83313
|
data = Buffer.from(data, "utf-8");
|
|
83528
83314
|
} 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,
|
|
83315
|
+
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
83316
|
}
|
|
83531
83317
|
headers.setContentLength(data.length, false);
|
|
83532
|
-
if (
|
|
83533
|
-
return reject(new AxiosError_default("Request body larger than maxBodyLength limit", AxiosError_default.ERR_BAD_REQUEST,
|
|
83318
|
+
if (config.maxBodyLength > -1 && data.length > config.maxBodyLength) {
|
|
83319
|
+
return reject(new AxiosError_default("Request body larger than maxBodyLength limit", AxiosError_default.ERR_BAD_REQUEST, config));
|
|
83534
83320
|
}
|
|
83535
83321
|
}
|
|
83536
83322
|
const contentLength = utils_default.toFiniteNumber(headers.getContentLength());
|
|
@@ -83550,9 +83336,9 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
|
83550
83336
|
onUploadProgress && data.on("progress", flushOnFinish(data, progressEventDecorator(contentLength, progressEventReducer(asyncDecorator(onUploadProgress), false, 3))));
|
|
83551
83337
|
}
|
|
83552
83338
|
let auth = undefined;
|
|
83553
|
-
if (
|
|
83554
|
-
const username =
|
|
83555
|
-
const password =
|
|
83339
|
+
if (config.auth) {
|
|
83340
|
+
const username = config.auth.username || "";
|
|
83341
|
+
const password = config.auth.password || "";
|
|
83556
83342
|
auth = username + ":" + password;
|
|
83557
83343
|
}
|
|
83558
83344
|
if (!auth && parsed.username) {
|
|
@@ -83563,11 +83349,11 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
|
83563
83349
|
auth && headers.delete("authorization");
|
|
83564
83350
|
let path3;
|
|
83565
83351
|
try {
|
|
83566
|
-
path3 = buildURL(parsed.pathname + parsed.search,
|
|
83352
|
+
path3 = buildURL(parsed.pathname + parsed.search, config.params, config.paramsSerializer).replace(/^\?/, "");
|
|
83567
83353
|
} catch (err) {
|
|
83568
83354
|
const customErr = new Error(err.message);
|
|
83569
|
-
customErr.config =
|
|
83570
|
-
customErr.url =
|
|
83355
|
+
customErr.config = config;
|
|
83356
|
+
customErr.url = config.url;
|
|
83571
83357
|
customErr.exists = true;
|
|
83572
83358
|
return reject(customErr);
|
|
83573
83359
|
}
|
|
@@ -83576,7 +83362,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
|
83576
83362
|
path: path3,
|
|
83577
83363
|
method,
|
|
83578
83364
|
headers: headers.toJSON(),
|
|
83579
|
-
agents: { http:
|
|
83365
|
+
agents: { http: config.httpAgent, https: config.httpsAgent },
|
|
83580
83366
|
auth,
|
|
83581
83367
|
protocol,
|
|
83582
83368
|
family,
|
|
@@ -83585,40 +83371,40 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
|
83585
83371
|
http2Options
|
|
83586
83372
|
};
|
|
83587
83373
|
!utils_default.isUndefined(lookup) && (options.lookup = lookup);
|
|
83588
|
-
if (
|
|
83589
|
-
options.socketPath =
|
|
83374
|
+
if (config.socketPath) {
|
|
83375
|
+
options.socketPath = config.socketPath;
|
|
83590
83376
|
} else {
|
|
83591
83377
|
options.hostname = parsed.hostname.startsWith("[") ? parsed.hostname.slice(1, -1) : parsed.hostname;
|
|
83592
83378
|
options.port = parsed.port;
|
|
83593
|
-
setProxy(options,
|
|
83379
|
+
setProxy(options, config.proxy, protocol + "//" + parsed.hostname + (parsed.port ? ":" + parsed.port : "") + options.path);
|
|
83594
83380
|
}
|
|
83595
83381
|
let transport;
|
|
83596
83382
|
const isHttpsRequest = isHttps.test(options.protocol);
|
|
83597
|
-
options.agent = isHttpsRequest ?
|
|
83383
|
+
options.agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
|
|
83598
83384
|
if (isHttp2) {
|
|
83599
83385
|
transport = http2Transport;
|
|
83600
83386
|
} else {
|
|
83601
|
-
if (
|
|
83602
|
-
transport =
|
|
83603
|
-
} else if (
|
|
83387
|
+
if (config.transport) {
|
|
83388
|
+
transport = config.transport;
|
|
83389
|
+
} else if (config.maxRedirects === 0) {
|
|
83604
83390
|
transport = isHttpsRequest ? https : http;
|
|
83605
83391
|
} else {
|
|
83606
|
-
if (
|
|
83607
|
-
options.maxRedirects =
|
|
83392
|
+
if (config.maxRedirects) {
|
|
83393
|
+
options.maxRedirects = config.maxRedirects;
|
|
83608
83394
|
}
|
|
83609
|
-
if (
|
|
83610
|
-
options.beforeRedirects.config =
|
|
83395
|
+
if (config.beforeRedirect) {
|
|
83396
|
+
options.beforeRedirects.config = config.beforeRedirect;
|
|
83611
83397
|
}
|
|
83612
83398
|
transport = isHttpsRequest ? httpsFollow : httpFollow;
|
|
83613
83399
|
}
|
|
83614
83400
|
}
|
|
83615
|
-
if (
|
|
83616
|
-
options.maxBodyLength =
|
|
83401
|
+
if (config.maxBodyLength > -1) {
|
|
83402
|
+
options.maxBodyLength = config.maxBodyLength;
|
|
83617
83403
|
} else {
|
|
83618
83404
|
options.maxBodyLength = Infinity;
|
|
83619
83405
|
}
|
|
83620
|
-
if (
|
|
83621
|
-
options.insecureHTTPParser =
|
|
83406
|
+
if (config.insecureHTTPParser) {
|
|
83407
|
+
options.insecureHTTPParser = config.insecureHTTPParser;
|
|
83622
83408
|
}
|
|
83623
83409
|
req = transport.request(options, function handleResponse(res) {
|
|
83624
83410
|
if (req.destroyed)
|
|
@@ -83634,7 +83420,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
|
83634
83420
|
}
|
|
83635
83421
|
let responseStream = res;
|
|
83636
83422
|
const lastRequest = res.req || req;
|
|
83637
|
-
if (
|
|
83423
|
+
if (config.decompress !== false && res.headers["content-encoding"]) {
|
|
83638
83424
|
if (method === "HEAD" || res.statusCode === 204) {
|
|
83639
83425
|
delete res.headers["content-encoding"];
|
|
83640
83426
|
}
|
|
@@ -83663,7 +83449,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
|
83663
83449
|
status: res.statusCode,
|
|
83664
83450
|
statusText: res.statusMessage,
|
|
83665
83451
|
headers: new AxiosHeaders_default(res.headers),
|
|
83666
|
-
config
|
|
83452
|
+
config,
|
|
83667
83453
|
request: lastRequest
|
|
83668
83454
|
};
|
|
83669
83455
|
if (responseType === "stream") {
|
|
@@ -83675,24 +83461,24 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
|
83675
83461
|
responseStream.on("data", function handleStreamData(chunk) {
|
|
83676
83462
|
responseBuffer.push(chunk);
|
|
83677
83463
|
totalResponseBytes += chunk.length;
|
|
83678
|
-
if (
|
|
83464
|
+
if (config.maxContentLength > -1 && totalResponseBytes > config.maxContentLength) {
|
|
83679
83465
|
rejected = true;
|
|
83680
83466
|
responseStream.destroy();
|
|
83681
|
-
abort(new AxiosError_default("maxContentLength size of " +
|
|
83467
|
+
abort(new AxiosError_default("maxContentLength size of " + config.maxContentLength + " exceeded", AxiosError_default.ERR_BAD_RESPONSE, config, lastRequest));
|
|
83682
83468
|
}
|
|
83683
83469
|
});
|
|
83684
83470
|
responseStream.on("aborted", function handlerStreamAborted() {
|
|
83685
83471
|
if (rejected) {
|
|
83686
83472
|
return;
|
|
83687
83473
|
}
|
|
83688
|
-
const err = new AxiosError_default("stream has been aborted", AxiosError_default.ERR_BAD_RESPONSE,
|
|
83474
|
+
const err = new AxiosError_default("stream has been aborted", AxiosError_default.ERR_BAD_RESPONSE, config, lastRequest);
|
|
83689
83475
|
responseStream.destroy(err);
|
|
83690
83476
|
reject(err);
|
|
83691
83477
|
});
|
|
83692
83478
|
responseStream.on("error", function handleStreamError(err) {
|
|
83693
83479
|
if (req.destroyed)
|
|
83694
83480
|
return;
|
|
83695
|
-
reject(AxiosError_default.from(err, null,
|
|
83481
|
+
reject(AxiosError_default.from(err, null, config, lastRequest));
|
|
83696
83482
|
});
|
|
83697
83483
|
responseStream.on("end", function handleStreamEnd() {
|
|
83698
83484
|
try {
|
|
@@ -83705,7 +83491,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
|
83705
83491
|
}
|
|
83706
83492
|
response.data = responseData;
|
|
83707
83493
|
} catch (err) {
|
|
83708
|
-
return reject(AxiosError_default.from(err, null,
|
|
83494
|
+
return reject(AxiosError_default.from(err, null, config, response.request, response));
|
|
83709
83495
|
}
|
|
83710
83496
|
settle(resolve3, reject, response);
|
|
83711
83497
|
});
|
|
@@ -83725,26 +83511,26 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
|
83725
83511
|
}
|
|
83726
83512
|
});
|
|
83727
83513
|
req.on("error", function handleRequestError(err) {
|
|
83728
|
-
reject(AxiosError_default.from(err, null,
|
|
83514
|
+
reject(AxiosError_default.from(err, null, config, req));
|
|
83729
83515
|
});
|
|
83730
83516
|
req.on("socket", function handleRequestSocket(socket) {
|
|
83731
83517
|
socket.setKeepAlive(true, 1000 * 60);
|
|
83732
83518
|
});
|
|
83733
|
-
if (
|
|
83734
|
-
const timeout = parseInt(
|
|
83519
|
+
if (config.timeout) {
|
|
83520
|
+
const timeout = parseInt(config.timeout, 10);
|
|
83735
83521
|
if (Number.isNaN(timeout)) {
|
|
83736
|
-
abort(new AxiosError_default("error trying to parse `config.timeout` to int", AxiosError_default.ERR_BAD_OPTION_VALUE,
|
|
83522
|
+
abort(new AxiosError_default("error trying to parse `config.timeout` to int", AxiosError_default.ERR_BAD_OPTION_VALUE, config, req));
|
|
83737
83523
|
return;
|
|
83738
83524
|
}
|
|
83739
83525
|
req.setTimeout(timeout, function handleRequestTimeout() {
|
|
83740
83526
|
if (isDone)
|
|
83741
83527
|
return;
|
|
83742
|
-
let timeoutErrorMessage =
|
|
83743
|
-
const transitional =
|
|
83744
|
-
if (
|
|
83745
|
-
timeoutErrorMessage =
|
|
83528
|
+
let timeoutErrorMessage = config.timeout ? "timeout of " + config.timeout + "ms exceeded" : "timeout exceeded";
|
|
83529
|
+
const transitional = config.transitional || transitional_default;
|
|
83530
|
+
if (config.timeoutErrorMessage) {
|
|
83531
|
+
timeoutErrorMessage = config.timeoutErrorMessage;
|
|
83746
83532
|
}
|
|
83747
|
-
abort(new AxiosError_default(timeoutErrorMessage, transitional.clarifyTimeoutError ? AxiosError_default.ETIMEDOUT : AxiosError_default.ECONNABORTED,
|
|
83533
|
+
abort(new AxiosError_default(timeoutErrorMessage, transitional.clarifyTimeoutError ? AxiosError_default.ETIMEDOUT : AxiosError_default.ECONNABORTED, config, req));
|
|
83748
83534
|
});
|
|
83749
83535
|
} else {
|
|
83750
83536
|
req.setTimeout(0);
|
|
@@ -83761,7 +83547,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
|
83761
83547
|
});
|
|
83762
83548
|
data.on("close", () => {
|
|
83763
83549
|
if (!ended && !errored) {
|
|
83764
|
-
abort(new CanceledError_default("Request stream has been aborted",
|
|
83550
|
+
abort(new CanceledError_default("Request stream has been aborted", config, req));
|
|
83765
83551
|
}
|
|
83766
83552
|
});
|
|
83767
83553
|
data.pipe(req);
|
|
@@ -83822,7 +83608,7 @@ var cookies_default = platform_default.hasStandardBrowserEnv ? {
|
|
|
83822
83608
|
var headersToObject = (thing) => thing instanceof AxiosHeaders_default ? { ...thing } : thing;
|
|
83823
83609
|
function mergeConfig(config1, config2) {
|
|
83824
83610
|
config2 = config2 || {};
|
|
83825
|
-
const
|
|
83611
|
+
const config = {};
|
|
83826
83612
|
function getMergedValue(target, source, prop, caseless) {
|
|
83827
83613
|
if (utils_default.isPlainObject(target) && utils_default.isPlainObject(source)) {
|
|
83828
83614
|
return utils_default.merge.call({ caseless }, target, source);
|
|
@@ -83893,17 +83679,17 @@ function mergeConfig(config1, config2) {
|
|
|
83893
83679
|
utils_default.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) {
|
|
83894
83680
|
const merge2 = mergeMap[prop] || mergeDeepProperties;
|
|
83895
83681
|
const configValue = merge2(config1[prop], config2[prop], prop);
|
|
83896
|
-
utils_default.isUndefined(configValue) && merge2 !== mergeDirectKeys || (
|
|
83682
|
+
utils_default.isUndefined(configValue) && merge2 !== mergeDirectKeys || (config[prop] = configValue);
|
|
83897
83683
|
});
|
|
83898
|
-
return
|
|
83684
|
+
return config;
|
|
83899
83685
|
}
|
|
83900
83686
|
|
|
83901
83687
|
// ../../node_modules/axios/lib/helpers/resolveConfig.js
|
|
83902
|
-
var resolveConfig_default = (
|
|
83903
|
-
const newConfig = mergeConfig({},
|
|
83688
|
+
var resolveConfig_default = (config) => {
|
|
83689
|
+
const newConfig = mergeConfig({}, config);
|
|
83904
83690
|
let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
|
|
83905
83691
|
newConfig.headers = headers = AxiosHeaders_default.from(headers);
|
|
83906
|
-
newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls),
|
|
83692
|
+
newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls), config.params, config.paramsSerializer);
|
|
83907
83693
|
if (auth) {
|
|
83908
83694
|
headers.set("Authorization", "Basic " + btoa((auth.username || "") + ":" + (auth.password ? unescape(encodeURIComponent(auth.password)) : "")));
|
|
83909
83695
|
}
|
|
@@ -83934,9 +83720,9 @@ var resolveConfig_default = (config2) => {
|
|
|
83934
83720
|
|
|
83935
83721
|
// ../../node_modules/axios/lib/adapters/xhr.js
|
|
83936
83722
|
var isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
|
|
83937
|
-
var xhr_default = isXHRAdapterSupported && function(
|
|
83723
|
+
var xhr_default = isXHRAdapterSupported && function(config) {
|
|
83938
83724
|
return new Promise(function dispatchXhrRequest(resolve3, reject) {
|
|
83939
|
-
const _config = resolveConfig_default(
|
|
83725
|
+
const _config = resolveConfig_default(config);
|
|
83940
83726
|
let requestData = _config.data;
|
|
83941
83727
|
const requestHeaders = AxiosHeaders_default.from(_config.headers).normalize();
|
|
83942
83728
|
let { responseType, onUploadProgress, onDownloadProgress } = _config;
|
|
@@ -83963,7 +83749,7 @@ var xhr_default = isXHRAdapterSupported && function(config2) {
|
|
|
83963
83749
|
status: request.status,
|
|
83964
83750
|
statusText: request.statusText,
|
|
83965
83751
|
headers: responseHeaders,
|
|
83966
|
-
config
|
|
83752
|
+
config,
|
|
83967
83753
|
request
|
|
83968
83754
|
};
|
|
83969
83755
|
settle(function _resolve(value) {
|
|
@@ -83992,12 +83778,12 @@ var xhr_default = isXHRAdapterSupported && function(config2) {
|
|
|
83992
83778
|
if (!request) {
|
|
83993
83779
|
return;
|
|
83994
83780
|
}
|
|
83995
|
-
reject(new AxiosError_default("Request aborted", AxiosError_default.ECONNABORTED,
|
|
83781
|
+
reject(new AxiosError_default("Request aborted", AxiosError_default.ECONNABORTED, config, request));
|
|
83996
83782
|
request = null;
|
|
83997
83783
|
};
|
|
83998
83784
|
request.onerror = function handleError(event) {
|
|
83999
83785
|
const msg = event && event.message ? event.message : "Network Error";
|
|
84000
|
-
const err = new AxiosError_default(msg, AxiosError_default.ERR_NETWORK,
|
|
83786
|
+
const err = new AxiosError_default(msg, AxiosError_default.ERR_NETWORK, config, request);
|
|
84001
83787
|
err.event = event || null;
|
|
84002
83788
|
reject(err);
|
|
84003
83789
|
request = null;
|
|
@@ -84008,7 +83794,7 @@ var xhr_default = isXHRAdapterSupported && function(config2) {
|
|
|
84008
83794
|
if (_config.timeoutErrorMessage) {
|
|
84009
83795
|
timeoutErrorMessage = _config.timeoutErrorMessage;
|
|
84010
83796
|
}
|
|
84011
|
-
reject(new AxiosError_default(timeoutErrorMessage, transitional.clarifyTimeoutError ? AxiosError_default.ETIMEDOUT : AxiosError_default.ECONNABORTED,
|
|
83797
|
+
reject(new AxiosError_default(timeoutErrorMessage, transitional.clarifyTimeoutError ? AxiosError_default.ETIMEDOUT : AxiosError_default.ECONNABORTED, config, request));
|
|
84012
83798
|
request = null;
|
|
84013
83799
|
};
|
|
84014
83800
|
requestData === undefined && requestHeaders.setContentType(null);
|
|
@@ -84037,7 +83823,7 @@ var xhr_default = isXHRAdapterSupported && function(config2) {
|
|
|
84037
83823
|
if (!request) {
|
|
84038
83824
|
return;
|
|
84039
83825
|
}
|
|
84040
|
-
reject(!cancel || cancel.type ? new CanceledError_default(null,
|
|
83826
|
+
reject(!cancel || cancel.type ? new CanceledError_default(null, config, request) : cancel);
|
|
84041
83827
|
request.abort();
|
|
84042
83828
|
request = null;
|
|
84043
83829
|
};
|
|
@@ -84048,7 +83834,7 @@ var xhr_default = isXHRAdapterSupported && function(config2) {
|
|
|
84048
83834
|
}
|
|
84049
83835
|
const protocol = parseProtocol(_config.url);
|
|
84050
83836
|
if (protocol && platform_default.protocols.indexOf(protocol) === -1) {
|
|
84051
|
-
reject(new AxiosError_default("Unsupported protocol " + protocol + ":", AxiosError_default.ERR_BAD_REQUEST,
|
|
83837
|
+
reject(new AxiosError_default("Unsupported protocol " + protocol + ":", AxiosError_default.ERR_BAD_REQUEST, config));
|
|
84052
83838
|
return;
|
|
84053
83839
|
}
|
|
84054
83840
|
request.send(requestData || null);
|
|
@@ -84217,12 +84003,12 @@ var factory = (env) => {
|
|
|
84217
84003
|
};
|
|
84218
84004
|
isFetchSupported && (() => {
|
|
84219
84005
|
["text", "arrayBuffer", "blob", "formData", "stream"].forEach((type) => {
|
|
84220
|
-
!resolvers[type] && (resolvers[type] = (res,
|
|
84006
|
+
!resolvers[type] && (resolvers[type] = (res, config) => {
|
|
84221
84007
|
let method = res && res[type];
|
|
84222
84008
|
if (method) {
|
|
84223
84009
|
return method.call(res);
|
|
84224
84010
|
}
|
|
84225
|
-
throw new AxiosError_default(`Response type '${type}' is not supported`, AxiosError_default.ERR_NOT_SUPPORT,
|
|
84011
|
+
throw new AxiosError_default(`Response type '${type}' is not supported`, AxiosError_default.ERR_NOT_SUPPORT, config);
|
|
84226
84012
|
});
|
|
84227
84013
|
});
|
|
84228
84014
|
})();
|
|
@@ -84254,7 +84040,7 @@ var factory = (env) => {
|
|
|
84254
84040
|
const length = utils_default.toFiniteNumber(headers.getContentLength());
|
|
84255
84041
|
return length == null ? getBodyLength(body) : length;
|
|
84256
84042
|
};
|
|
84257
|
-
return async (
|
|
84043
|
+
return async (config) => {
|
|
84258
84044
|
let {
|
|
84259
84045
|
url: url2,
|
|
84260
84046
|
method,
|
|
@@ -84268,7 +84054,7 @@ var factory = (env) => {
|
|
|
84268
84054
|
headers,
|
|
84269
84055
|
withCredentials = "same-origin",
|
|
84270
84056
|
fetchOptions
|
|
84271
|
-
} = resolveConfig_default(
|
|
84057
|
+
} = resolveConfig_default(config);
|
|
84272
84058
|
let _fetch = envFetch || fetch;
|
|
84273
84059
|
responseType = responseType ? (responseType + "").toLowerCase() : "text";
|
|
84274
84060
|
let composedSignal = composeSignals_default([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
|
@@ -84322,7 +84108,7 @@ var factory = (env) => {
|
|
|
84322
84108
|
}), options);
|
|
84323
84109
|
}
|
|
84324
84110
|
responseType = responseType || "text";
|
|
84325
|
-
let responseData = await resolvers[utils_default.findKey(resolvers, responseType) || "text"](response,
|
|
84111
|
+
let responseData = await resolvers[utils_default.findKey(resolvers, responseType) || "text"](response, config);
|
|
84326
84112
|
!isStreamResponse && unsubscribe && unsubscribe();
|
|
84327
84113
|
return await new Promise((resolve3, reject) => {
|
|
84328
84114
|
settle(resolve3, reject, {
|
|
@@ -84330,24 +84116,24 @@ var factory = (env) => {
|
|
|
84330
84116
|
headers: AxiosHeaders_default.from(response.headers),
|
|
84331
84117
|
status: response.status,
|
|
84332
84118
|
statusText: response.statusText,
|
|
84333
|
-
config
|
|
84119
|
+
config,
|
|
84334
84120
|
request
|
|
84335
84121
|
});
|
|
84336
84122
|
});
|
|
84337
84123
|
} catch (err) {
|
|
84338
84124
|
unsubscribe && unsubscribe();
|
|
84339
84125
|
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,
|
|
84126
|
+
throw Object.assign(new AxiosError_default("Network Error", AxiosError_default.ERR_NETWORK, config, request), {
|
|
84341
84127
|
cause: err.cause || err
|
|
84342
84128
|
});
|
|
84343
84129
|
}
|
|
84344
|
-
throw AxiosError_default.from(err, err && err.code,
|
|
84130
|
+
throw AxiosError_default.from(err, err && err.code, config, request);
|
|
84345
84131
|
}
|
|
84346
84132
|
};
|
|
84347
84133
|
};
|
|
84348
84134
|
var seedCache = new Map;
|
|
84349
|
-
var getFetch = (
|
|
84350
|
-
let env =
|
|
84135
|
+
var getFetch = (config) => {
|
|
84136
|
+
let env = config && config.env || {};
|
|
84351
84137
|
const { fetch: fetch2, Request, Response } = env;
|
|
84352
84138
|
const seeds = [
|
|
84353
84139
|
Request,
|
|
@@ -84383,7 +84169,7 @@ utils_default.forEach(knownAdapters, (fn, value) => {
|
|
|
84383
84169
|
});
|
|
84384
84170
|
var renderReason = (reason) => `- ${reason}`;
|
|
84385
84171
|
var isResolvedHandle = (adapter2) => utils_default.isFunction(adapter2) || adapter2 === null || adapter2 === false;
|
|
84386
|
-
function getAdapter(adapters,
|
|
84172
|
+
function getAdapter(adapters, config) {
|
|
84387
84173
|
adapters = utils_default.isArray(adapters) ? adapters : [adapters];
|
|
84388
84174
|
const { length } = adapters;
|
|
84389
84175
|
let nameOrAdapter;
|
|
@@ -84399,7 +84185,7 @@ function getAdapter(adapters, config2) {
|
|
|
84399
84185
|
throw new AxiosError_default(`Unknown adapter '${id}'`);
|
|
84400
84186
|
}
|
|
84401
84187
|
}
|
|
84402
|
-
if (adapter2 && (utils_default.isFunction(adapter2) || (adapter2 = adapter2.get(
|
|
84188
|
+
if (adapter2 && (utils_default.isFunction(adapter2) || (adapter2 = adapter2.get(config)))) {
|
|
84403
84189
|
break;
|
|
84404
84190
|
}
|
|
84405
84191
|
rejectedReasons[id || "#" + i] = adapter2;
|
|
@@ -84419,32 +84205,32 @@ var adapters_default = {
|
|
|
84419
84205
|
};
|
|
84420
84206
|
|
|
84421
84207
|
// ../../node_modules/axios/lib/core/dispatchRequest.js
|
|
84422
|
-
function throwIfCancellationRequested(
|
|
84423
|
-
if (
|
|
84424
|
-
|
|
84208
|
+
function throwIfCancellationRequested(config) {
|
|
84209
|
+
if (config.cancelToken) {
|
|
84210
|
+
config.cancelToken.throwIfRequested();
|
|
84425
84211
|
}
|
|
84426
|
-
if (
|
|
84427
|
-
throw new CanceledError_default(null,
|
|
84212
|
+
if (config.signal && config.signal.aborted) {
|
|
84213
|
+
throw new CanceledError_default(null, config);
|
|
84428
84214
|
}
|
|
84429
84215
|
}
|
|
84430
|
-
function dispatchRequest(
|
|
84431
|
-
throwIfCancellationRequested(
|
|
84432
|
-
|
|
84433
|
-
|
|
84434
|
-
if (["post", "put", "patch"].indexOf(
|
|
84435
|
-
|
|
84216
|
+
function dispatchRequest(config) {
|
|
84217
|
+
throwIfCancellationRequested(config);
|
|
84218
|
+
config.headers = AxiosHeaders_default.from(config.headers);
|
|
84219
|
+
config.data = transformData.call(config, config.transformRequest);
|
|
84220
|
+
if (["post", "put", "patch"].indexOf(config.method) !== -1) {
|
|
84221
|
+
config.headers.setContentType("application/x-www-form-urlencoded", false);
|
|
84436
84222
|
}
|
|
84437
|
-
const adapter2 = adapters_default.getAdapter(
|
|
84438
|
-
return adapter2(
|
|
84439
|
-
throwIfCancellationRequested(
|
|
84440
|
-
response.data = transformData.call(
|
|
84223
|
+
const adapter2 = adapters_default.getAdapter(config.adapter || defaults_default.adapter, config);
|
|
84224
|
+
return adapter2(config).then(function onAdapterResolution(response) {
|
|
84225
|
+
throwIfCancellationRequested(config);
|
|
84226
|
+
response.data = transformData.call(config, config.transformResponse, response);
|
|
84441
84227
|
response.headers = AxiosHeaders_default.from(response.headers);
|
|
84442
84228
|
return response;
|
|
84443
84229
|
}, function onAdapterRejection(reason) {
|
|
84444
84230
|
if (!isCancel(reason)) {
|
|
84445
|
-
throwIfCancellationRequested(
|
|
84231
|
+
throwIfCancellationRequested(config);
|
|
84446
84232
|
if (reason && reason.response) {
|
|
84447
|
-
reason.response.data = transformData.call(
|
|
84233
|
+
reason.response.data = transformData.call(config, config.transformResponse, reason.response);
|
|
84448
84234
|
reason.response.headers = AxiosHeaders_default.from(reason.response.headers);
|
|
84449
84235
|
}
|
|
84450
84236
|
}
|
|
@@ -84519,9 +84305,9 @@ class Axios {
|
|
|
84519
84305
|
response: new InterceptorManager_default
|
|
84520
84306
|
};
|
|
84521
84307
|
}
|
|
84522
|
-
async request(configOrUrl,
|
|
84308
|
+
async request(configOrUrl, config) {
|
|
84523
84309
|
try {
|
|
84524
|
-
return await this._request(configOrUrl,
|
|
84310
|
+
return await this._request(configOrUrl, config);
|
|
84525
84311
|
} catch (err) {
|
|
84526
84312
|
if (err instanceof Error) {
|
|
84527
84313
|
let dummy = {};
|
|
@@ -84539,15 +84325,15 @@ class Axios {
|
|
|
84539
84325
|
throw err;
|
|
84540
84326
|
}
|
|
84541
84327
|
}
|
|
84542
|
-
_request(configOrUrl,
|
|
84328
|
+
_request(configOrUrl, config) {
|
|
84543
84329
|
if (typeof configOrUrl === "string") {
|
|
84544
|
-
|
|
84545
|
-
|
|
84330
|
+
config = config || {};
|
|
84331
|
+
config.url = configOrUrl;
|
|
84546
84332
|
} else {
|
|
84547
|
-
|
|
84333
|
+
config = configOrUrl || {};
|
|
84548
84334
|
}
|
|
84549
|
-
|
|
84550
|
-
const { transitional: transitional2, paramsSerializer, headers } =
|
|
84335
|
+
config = mergeConfig(this.defaults, config);
|
|
84336
|
+
const { transitional: transitional2, paramsSerializer, headers } = config;
|
|
84551
84337
|
if (transitional2 !== undefined) {
|
|
84552
84338
|
validator_default.assertOptions(transitional2, {
|
|
84553
84339
|
silentJSONParsing: validators2.transitional(validators2.boolean),
|
|
@@ -84557,7 +84343,7 @@ class Axios {
|
|
|
84557
84343
|
}
|
|
84558
84344
|
if (paramsSerializer != null) {
|
|
84559
84345
|
if (utils_default.isFunction(paramsSerializer)) {
|
|
84560
|
-
|
|
84346
|
+
config.paramsSerializer = {
|
|
84561
84347
|
serialize: paramsSerializer
|
|
84562
84348
|
};
|
|
84563
84349
|
} else {
|
|
@@ -84567,25 +84353,25 @@ class Axios {
|
|
|
84567
84353
|
}, true);
|
|
84568
84354
|
}
|
|
84569
84355
|
}
|
|
84570
|
-
if (
|
|
84571
|
-
|
|
84356
|
+
if (config.allowAbsoluteUrls !== undefined) {} else if (this.defaults.allowAbsoluteUrls !== undefined) {
|
|
84357
|
+
config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
|
|
84572
84358
|
} else {
|
|
84573
|
-
|
|
84359
|
+
config.allowAbsoluteUrls = true;
|
|
84574
84360
|
}
|
|
84575
|
-
validator_default.assertOptions(
|
|
84361
|
+
validator_default.assertOptions(config, {
|
|
84576
84362
|
baseUrl: validators2.spelling("baseURL"),
|
|
84577
84363
|
withXsrfToken: validators2.spelling("withXSRFToken")
|
|
84578
84364
|
}, true);
|
|
84579
|
-
|
|
84580
|
-
let contextHeaders = headers && utils_default.merge(headers.common, headers[
|
|
84365
|
+
config.method = (config.method || this.defaults.method || "get").toLowerCase();
|
|
84366
|
+
let contextHeaders = headers && utils_default.merge(headers.common, headers[config.method]);
|
|
84581
84367
|
headers && utils_default.forEach(["delete", "get", "head", "post", "put", "patch", "common"], (method) => {
|
|
84582
84368
|
delete headers[method];
|
|
84583
84369
|
});
|
|
84584
|
-
|
|
84370
|
+
config.headers = AxiosHeaders_default.concat(contextHeaders, headers);
|
|
84585
84371
|
const requestInterceptorChain = [];
|
|
84586
84372
|
let synchronousRequestInterceptors = true;
|
|
84587
84373
|
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
|
84588
|
-
if (typeof interceptor.runWhen === "function" && interceptor.runWhen(
|
|
84374
|
+
if (typeof interceptor.runWhen === "function" && interceptor.runWhen(config) === false) {
|
|
84589
84375
|
return;
|
|
84590
84376
|
}
|
|
84591
84377
|
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
|
@@ -84603,14 +84389,14 @@ class Axios {
|
|
|
84603
84389
|
chain.unshift(...requestInterceptorChain);
|
|
84604
84390
|
chain.push(...responseInterceptorChain);
|
|
84605
84391
|
len = chain.length;
|
|
84606
|
-
promise = Promise.resolve(
|
|
84392
|
+
promise = Promise.resolve(config);
|
|
84607
84393
|
while (i < len) {
|
|
84608
84394
|
promise = promise.then(chain[i++], chain[i++]);
|
|
84609
84395
|
}
|
|
84610
84396
|
return promise;
|
|
84611
84397
|
}
|
|
84612
84398
|
len = requestInterceptorChain.length;
|
|
84613
|
-
let newConfig =
|
|
84399
|
+
let newConfig = config;
|
|
84614
84400
|
while (i < len) {
|
|
84615
84401
|
const onFulfilled = requestInterceptorChain[i++];
|
|
84616
84402
|
const onRejected = requestInterceptorChain[i++];
|
|
@@ -84633,25 +84419,25 @@ class Axios {
|
|
|
84633
84419
|
}
|
|
84634
84420
|
return promise;
|
|
84635
84421
|
}
|
|
84636
|
-
getUri(
|
|
84637
|
-
|
|
84638
|
-
const fullPath = buildFullPath(
|
|
84639
|
-
return buildURL(fullPath,
|
|
84422
|
+
getUri(config) {
|
|
84423
|
+
config = mergeConfig(this.defaults, config);
|
|
84424
|
+
const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
|
|
84425
|
+
return buildURL(fullPath, config.params, config.paramsSerializer);
|
|
84640
84426
|
}
|
|
84641
84427
|
}
|
|
84642
84428
|
utils_default.forEach(["delete", "get", "head", "options"], function forEachMethodNoData(method) {
|
|
84643
|
-
Axios.prototype[method] = function(url2,
|
|
84644
|
-
return this.request(mergeConfig(
|
|
84429
|
+
Axios.prototype[method] = function(url2, config) {
|
|
84430
|
+
return this.request(mergeConfig(config || {}, {
|
|
84645
84431
|
method,
|
|
84646
84432
|
url: url2,
|
|
84647
|
-
data: (
|
|
84433
|
+
data: (config || {}).data
|
|
84648
84434
|
}));
|
|
84649
84435
|
};
|
|
84650
84436
|
});
|
|
84651
84437
|
utils_default.forEach(["post", "put", "patch"], function forEachMethodWithData(method) {
|
|
84652
84438
|
function generateHTTPMethod(isForm) {
|
|
84653
|
-
return function httpMethod(url2, data,
|
|
84654
|
-
return this.request(mergeConfig(
|
|
84439
|
+
return function httpMethod(url2, data, config) {
|
|
84440
|
+
return this.request(mergeConfig(config || {}, {
|
|
84655
84441
|
method,
|
|
84656
84442
|
headers: isForm ? {
|
|
84657
84443
|
"Content-Type": "multipart/form-data"
|
|
@@ -84697,11 +84483,11 @@ class CancelToken {
|
|
|
84697
84483
|
};
|
|
84698
84484
|
return promise;
|
|
84699
84485
|
};
|
|
84700
|
-
executor(function cancel(message,
|
|
84486
|
+
executor(function cancel(message, config, request) {
|
|
84701
84487
|
if (token.reason) {
|
|
84702
84488
|
return;
|
|
84703
84489
|
}
|
|
84704
|
-
token.reason = new CanceledError_default(message,
|
|
84490
|
+
token.reason = new CanceledError_default(message, config, request);
|
|
84705
84491
|
resolvePromise(token.reason);
|
|
84706
84492
|
});
|
|
84707
84493
|
}
|
|
@@ -84878,20 +84664,20 @@ var axios_default = axios;
|
|
|
84878
84664
|
class RestApiClient {
|
|
84879
84665
|
client;
|
|
84880
84666
|
config;
|
|
84881
|
-
constructor(
|
|
84882
|
-
this.config =
|
|
84883
|
-
const auth = Buffer.from(`${
|
|
84667
|
+
constructor(config) {
|
|
84668
|
+
this.config = config;
|
|
84669
|
+
const auth = Buffer.from(`${config.username}:${config.applicationPassword}`).toString("base64");
|
|
84884
84670
|
this.client = axios_default.create({
|
|
84885
|
-
baseURL: `${
|
|
84671
|
+
baseURL: `${config.wordpressUrl}/wp-json/wp/v2`,
|
|
84886
84672
|
headers: {
|
|
84887
84673
|
Authorization: `Basic ${auth}`,
|
|
84888
84674
|
"Content-Type": "application/json"
|
|
84889
84675
|
},
|
|
84890
84676
|
timeout: 30000
|
|
84891
84677
|
});
|
|
84892
|
-
this.client.interceptors.request.use((
|
|
84893
|
-
logger.debug(`Making request: ${
|
|
84894
|
-
return
|
|
84678
|
+
this.client.interceptors.request.use((config2) => {
|
|
84679
|
+
logger.debug(`Making request: ${config2.method?.toUpperCase()} ${config2.url}`);
|
|
84680
|
+
return config2;
|
|
84895
84681
|
}, (error) => {
|
|
84896
84682
|
logger.error("Request error:", error);
|
|
84897
84683
|
return Promise.reject(error);
|
|
@@ -85049,8 +84835,8 @@ var mysql = __toESM(require_promise(), 1);
|
|
|
85049
84835
|
class DatabaseClient {
|
|
85050
84836
|
connection = null;
|
|
85051
84837
|
config;
|
|
85052
|
-
constructor(
|
|
85053
|
-
this.config =
|
|
84838
|
+
constructor(config) {
|
|
84839
|
+
this.config = config;
|
|
85054
84840
|
}
|
|
85055
84841
|
async connect() {
|
|
85056
84842
|
if (this.connection) {
|
|
@@ -85147,8 +84933,7 @@ class DatabaseClient {
|
|
|
85147
84933
|
const perPage = params.per_page || 100;
|
|
85148
84934
|
const page = params.page || 1;
|
|
85149
84935
|
const offset = (page - 1) * perPage;
|
|
85150
|
-
query +=
|
|
85151
|
-
queryParams.push(perPage, offset);
|
|
84936
|
+
query += ` LIMIT ${Number(perPage)} OFFSET ${Number(offset)}`;
|
|
85152
84937
|
logger.debug(`Executing query: ${query}`);
|
|
85153
84938
|
logger.debug(`Query parameters: ${JSON.stringify(queryParams)}`);
|
|
85154
84939
|
const [rows] = await this.connection.execute(query, queryParams);
|
|
@@ -85464,6 +85249,7 @@ class DatabaseClient {
|
|
|
85464
85249
|
class ConnectionManager {
|
|
85465
85250
|
static instance;
|
|
85466
85251
|
connection = null;
|
|
85252
|
+
currentConfig = null;
|
|
85467
85253
|
constructor() {}
|
|
85468
85254
|
static getInstance() {
|
|
85469
85255
|
if (!ConnectionManager.instance) {
|
|
@@ -85471,20 +85257,44 @@ class ConnectionManager {
|
|
|
85471
85257
|
}
|
|
85472
85258
|
return ConnectionManager.instance;
|
|
85473
85259
|
}
|
|
85474
|
-
|
|
85475
|
-
|
|
85476
|
-
|
|
85477
|
-
|
|
85478
|
-
|
|
85260
|
+
hasConnection() {
|
|
85261
|
+
return this.connection !== null;
|
|
85262
|
+
}
|
|
85263
|
+
async createConnection(config) {
|
|
85264
|
+
if (this.connection && this.currentConfig) {
|
|
85265
|
+
const configMatches = this.configsMatch(this.currentConfig, config);
|
|
85266
|
+
if (configMatches) {
|
|
85267
|
+
return this.connection;
|
|
85268
|
+
}
|
|
85269
|
+
await this.closeConnection();
|
|
85270
|
+
}
|
|
85271
|
+
if (config.type === "rest-api") {
|
|
85272
|
+
this.connection = new RestApiClient(config);
|
|
85273
|
+
} else if (config.type === "database") {
|
|
85274
|
+
this.connection = new DatabaseClient(config);
|
|
85479
85275
|
} else {
|
|
85480
|
-
throw new Error(`Unsupported connection type: ${
|
|
85276
|
+
throw new Error(`Unsupported connection type: ${config.type}`);
|
|
85481
85277
|
}
|
|
85482
85278
|
const isConnected = await this.connection.testConnection();
|
|
85483
85279
|
if (!isConnected) {
|
|
85484
85280
|
throw new Error("Failed to establish connection to WordPress");
|
|
85485
85281
|
}
|
|
85282
|
+
this.currentConfig = config;
|
|
85486
85283
|
return this.connection;
|
|
85487
85284
|
}
|
|
85285
|
+
configsMatch(a, b) {
|
|
85286
|
+
if (a.type !== b.type)
|
|
85287
|
+
return false;
|
|
85288
|
+
if (a.wordpressUrl !== b.wordpressUrl)
|
|
85289
|
+
return false;
|
|
85290
|
+
if (a.type === "database" && b.type === "database") {
|
|
85291
|
+
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;
|
|
85292
|
+
}
|
|
85293
|
+
if (a.type === "rest-api" && b.type === "rest-api") {
|
|
85294
|
+
return a.username === b.username;
|
|
85295
|
+
}
|
|
85296
|
+
return true;
|
|
85297
|
+
}
|
|
85488
85298
|
getConnection() {
|
|
85489
85299
|
if (!this.connection) {
|
|
85490
85300
|
throw new Error("No connection established. Call createConnection() first.");
|
|
@@ -85496,6 +85306,7 @@ class ConnectionManager {
|
|
|
85496
85306
|
await this.connection.close();
|
|
85497
85307
|
}
|
|
85498
85308
|
this.connection = null;
|
|
85309
|
+
this.currentConfig = null;
|
|
85499
85310
|
}
|
|
85500
85311
|
}
|
|
85501
85312
|
// ../../node_modules/@wordpress/block-serialization-default-parser/build-module/index.js
|
|
@@ -85980,8 +85791,9 @@ class PullCommand {
|
|
|
85980
85791
|
}
|
|
85981
85792
|
async execute(options) {
|
|
85982
85793
|
logger.progress("Starting pull operation...");
|
|
85983
|
-
const
|
|
85984
|
-
const
|
|
85794
|
+
const config = this.configManager.getConfig();
|
|
85795
|
+
const legacyConfig = this.configManager.getLegacyConfig();
|
|
85796
|
+
const connection = await this.connectionManager.createConnection(legacyConfig.wordpress);
|
|
85985
85797
|
const result2 = {
|
|
85986
85798
|
success: false,
|
|
85987
85799
|
operation: {
|
|
@@ -85993,7 +85805,7 @@ class PullCommand {
|
|
|
85993
85805
|
},
|
|
85994
85806
|
target: {
|
|
85995
85807
|
type: "local",
|
|
85996
|
-
identifier: options.outputDir ||
|
|
85808
|
+
identifier: options.outputDir || config.paths.content,
|
|
85997
85809
|
lastModified: new Date
|
|
85998
85810
|
},
|
|
85999
85811
|
timestamp: new Date,
|
|
@@ -86003,8 +85815,8 @@ class PullCommand {
|
|
|
86003
85815
|
errors: []
|
|
86004
85816
|
};
|
|
86005
85817
|
try {
|
|
86006
|
-
const postTypes = options.postTypes ||
|
|
86007
|
-
const outputDir = options.outputDir ||
|
|
85818
|
+
const postTypes = options.postTypes || ["post", "page"];
|
|
85819
|
+
const outputDir = options.outputDir || config.paths.content;
|
|
86008
85820
|
fs3.mkdirSync(outputDir, { recursive: true });
|
|
86009
85821
|
let totalProcessed = 0;
|
|
86010
85822
|
for (const postType of postTypes) {
|
|
@@ -86079,13 +85891,7 @@ class PullCommand {
|
|
|
86079
85891
|
title: post.title.rendered,
|
|
86080
85892
|
slug: post.slug,
|
|
86081
85893
|
postId: post.id,
|
|
86082
|
-
status: post.status
|
|
86083
|
-
date: new Date(post.date).toISOString(),
|
|
86084
|
-
modified: new Date(post.modified).toISOString(),
|
|
86085
|
-
excerpt: post.excerpt.rendered || "",
|
|
86086
|
-
categories: post.categories || [],
|
|
86087
|
-
tags: post.tags || [],
|
|
86088
|
-
meta: post.meta || {}
|
|
85894
|
+
status: post.status
|
|
86089
85895
|
};
|
|
86090
85896
|
const mdxContent = this.generateMDX(blocks, frontmatter);
|
|
86091
85897
|
fs3.writeFileSync(filePath2, mdxContent, "utf8");
|
|
@@ -92118,8 +91924,8 @@ function walk(ast, { enter, leave }) {
|
|
|
92118
91924
|
// ../../node_modules/estree-util-build-jsx/lib/index.js
|
|
92119
91925
|
var regex = /@(jsx|jsxFrag|jsxImportSource|jsxRuntime)\s+(\S+)/g;
|
|
92120
91926
|
function buildJsx(tree, options) {
|
|
92121
|
-
const
|
|
92122
|
-
let automatic =
|
|
91927
|
+
const config = options || {};
|
|
91928
|
+
let automatic = config.runtime === "automatic";
|
|
92123
91929
|
const annotations = {};
|
|
92124
91930
|
const imports = {};
|
|
92125
91931
|
walk(tree, {
|
|
@@ -92201,7 +92007,7 @@ function buildJsx(tree, options) {
|
|
|
92201
92007
|
specifiers,
|
|
92202
92008
|
source: {
|
|
92203
92009
|
type: "Literal",
|
|
92204
|
-
value: (annotations.jsxImportSource ||
|
|
92010
|
+
value: (annotations.jsxImportSource || config.importSource || "react") + (config.development ? "/jsx-dev-runtime" : "/jsx-runtime")
|
|
92205
92011
|
}
|
|
92206
92012
|
});
|
|
92207
92013
|
}
|
|
@@ -92272,7 +92078,7 @@ function buildJsx(tree, options) {
|
|
|
92272
92078
|
imports.fragment = true;
|
|
92273
92079
|
name2 = { type: "Identifier", name: "_Fragment" };
|
|
92274
92080
|
} else {
|
|
92275
|
-
name2 = toMemberExpression(annotations.jsxFrag ||
|
|
92081
|
+
name2 = toMemberExpression(annotations.jsxFrag || config.pragmaFrag || "React.Fragment");
|
|
92276
92082
|
}
|
|
92277
92083
|
if (automatic) {
|
|
92278
92084
|
if (children.length > 0) {
|
|
@@ -92294,11 +92100,11 @@ function buildJsx(tree, options) {
|
|
|
92294
92100
|
parameters.push({ type: "ObjectExpression", properties: fields });
|
|
92295
92101
|
if (key) {
|
|
92296
92102
|
parameters.push(key);
|
|
92297
|
-
} else if (
|
|
92103
|
+
} else if (config.development) {
|
|
92298
92104
|
parameters.push({ type: "Identifier", name: "undefined" });
|
|
92299
92105
|
}
|
|
92300
92106
|
const isStaticChildren = children.length > 1;
|
|
92301
|
-
if (
|
|
92107
|
+
if (config.development) {
|
|
92302
92108
|
imports.jsxDEV = true;
|
|
92303
92109
|
callee = {
|
|
92304
92110
|
type: "Identifier",
|
|
@@ -92317,7 +92123,7 @@ function buildJsx(tree, options) {
|
|
|
92317
92123
|
key: { type: "Identifier", name: "fileName" },
|
|
92318
92124
|
value: {
|
|
92319
92125
|
type: "Literal",
|
|
92320
|
-
value:
|
|
92126
|
+
value: config.filePath || "<source.js>"
|
|
92321
92127
|
}
|
|
92322
92128
|
}
|
|
92323
92129
|
]
|
|
@@ -92355,7 +92161,7 @@ function buildJsx(tree, options) {
|
|
|
92355
92161
|
} else if (parameters.length > 0) {
|
|
92356
92162
|
parameters.unshift({ type: "Literal", value: null });
|
|
92357
92163
|
}
|
|
92358
|
-
callee = toMemberExpression(annotations.jsx ||
|
|
92164
|
+
callee = toMemberExpression(annotations.jsx || config.pragma || "React.createElement");
|
|
92359
92165
|
}
|
|
92360
92166
|
parameters.unshift(name2);
|
|
92361
92167
|
const call = {
|
|
@@ -109224,7 +109030,7 @@ function fromMarkdown(value, encoding, options) {
|
|
|
109224
109030
|
return compiler(options)(postprocess(parse4(options).document().write(preprocess()(value, encoding, true))));
|
|
109225
109031
|
}
|
|
109226
109032
|
function compiler(options) {
|
|
109227
|
-
const
|
|
109033
|
+
const config = {
|
|
109228
109034
|
transforms: [],
|
|
109229
109035
|
canContainEols: ["emphasis", "fragment", "heading", "paragraph", "strong"],
|
|
109230
109036
|
enter: {
|
|
@@ -109322,7 +109128,7 @@ function compiler(options) {
|
|
|
109322
109128
|
thematicBreak: closer()
|
|
109323
109129
|
}
|
|
109324
109130
|
};
|
|
109325
|
-
configure(
|
|
109131
|
+
configure(config, (options || {}).mdastExtensions || []);
|
|
109326
109132
|
const data2 = {};
|
|
109327
109133
|
return compile;
|
|
109328
109134
|
function compile(events) {
|
|
@@ -109330,7 +109136,7 @@ function compiler(options) {
|
|
|
109330
109136
|
const context = {
|
|
109331
109137
|
stack: [tree],
|
|
109332
109138
|
tokenStack: [],
|
|
109333
|
-
config
|
|
109139
|
+
config,
|
|
109334
109140
|
enter,
|
|
109335
109141
|
exit: exit2,
|
|
109336
109142
|
buffer,
|
|
@@ -109352,7 +109158,7 @@ function compiler(options) {
|
|
|
109352
109158
|
}
|
|
109353
109159
|
index2 = -1;
|
|
109354
109160
|
while (++index2 < events.length) {
|
|
109355
|
-
const handler =
|
|
109161
|
+
const handler = config[events[index2][0]];
|
|
109356
109162
|
if (own7.call(handler, events[index2][1].type)) {
|
|
109357
109163
|
handler[events[index2][1].type].call(Object.assign({ sliceSerialize: events[index2][2].sliceSerialize }, context), events[index2][1]);
|
|
109358
109164
|
}
|
|
@@ -109367,8 +109173,8 @@ function compiler(options) {
|
|
|
109367
109173
|
end: point3(events.length > 0 ? events[events.length - 2][1].end : { line: 1, column: 1, offset: 0 })
|
|
109368
109174
|
};
|
|
109369
109175
|
index2 = -1;
|
|
109370
|
-
while (++index2 <
|
|
109371
|
-
tree =
|
|
109176
|
+
while (++index2 < config.transforms.length) {
|
|
109177
|
+
tree = config.transforms[index2](tree) || tree;
|
|
109372
109178
|
}
|
|
109373
109179
|
return tree;
|
|
109374
109180
|
}
|
|
@@ -109639,7 +109445,7 @@ function compiler(options) {
|
|
|
109639
109445
|
this.data.atHardBreak = undefined;
|
|
109640
109446
|
return;
|
|
109641
109447
|
}
|
|
109642
|
-
if (!this.data.setextHeadingSlurpLineEnding &&
|
|
109448
|
+
if (!this.data.setextHeadingSlurpLineEnding && config.canContainEols.includes(context.type)) {
|
|
109643
109449
|
onenterdata.call(this, token);
|
|
109644
109450
|
onexitdata.call(this, token);
|
|
109645
109451
|
}
|
|
@@ -113251,8 +113057,8 @@ class PushCommand {
|
|
|
113251
113057
|
if (blockRegistry) {
|
|
113252
113058
|
this.blockRegistry = blockRegistry;
|
|
113253
113059
|
} else {
|
|
113254
|
-
const
|
|
113255
|
-
const buildOutputDir = this.configManager.resolvePath(
|
|
113060
|
+
const config = this.configManager.getConfig();
|
|
113061
|
+
const buildOutputDir = this.configManager.resolvePath(config.paths.dist);
|
|
113256
113062
|
this.blockRegistry = new BlockRegistry(buildOutputDir);
|
|
113257
113063
|
}
|
|
113258
113064
|
}
|
|
@@ -113329,8 +113135,9 @@ class PushCommand {
|
|
|
113329
113135
|
logger.warn(`Failed to load built blocks: ${error.message}`);
|
|
113330
113136
|
logger.warn("Continuing with basic block rendering...");
|
|
113331
113137
|
}
|
|
113332
|
-
const
|
|
113333
|
-
const
|
|
113138
|
+
const config = this.configManager.getConfig();
|
|
113139
|
+
const legacyConfig = this.configManager.getLegacyConfig();
|
|
113140
|
+
const connection = await this.connectionManager.createConnection(legacyConfig.wordpress);
|
|
113334
113141
|
const result2 = {
|
|
113335
113142
|
success: false,
|
|
113336
113143
|
operation: {
|
|
@@ -113342,7 +113149,7 @@ class PushCommand {
|
|
|
113342
113149
|
},
|
|
113343
113150
|
target: {
|
|
113344
113151
|
type: "wordpress",
|
|
113345
|
-
identifier:
|
|
113152
|
+
identifier: this.configManager.getWordPressUrl(),
|
|
113346
113153
|
lastModified: new Date
|
|
113347
113154
|
},
|
|
113348
113155
|
timestamp: new Date,
|
|
@@ -113353,7 +113160,7 @@ class PushCommand {
|
|
|
113353
113160
|
conflicts: []
|
|
113354
113161
|
};
|
|
113355
113162
|
try {
|
|
113356
|
-
const mdxFiles = await this.findMDXFiles(options.files,
|
|
113163
|
+
const mdxFiles = await this.findMDXFiles(options.files, config.paths.content);
|
|
113357
113164
|
if (mdxFiles.length === 0) {
|
|
113358
113165
|
logger.warn("No MDX files found to push");
|
|
113359
113166
|
result2.operation.status = "completed";
|
|
@@ -113383,7 +113190,7 @@ class PushCommand {
|
|
|
113383
113190
|
logger.warn(`Found ${result2.conflicts.length} file(s) with conflicts (WordPress version is newer)`);
|
|
113384
113191
|
logger.info(`Use --force to override, or pull latest changes first`);
|
|
113385
113192
|
logger.debug(`Conflict details:`);
|
|
113386
|
-
await this.handleConflicts(result2.conflicts,
|
|
113193
|
+
await this.handleConflicts(result2.conflicts, config.sync.conflictResolution);
|
|
113387
113194
|
}
|
|
113388
113195
|
result2.operation.status = "completed";
|
|
113389
113196
|
result2.success = result2.errors.length === 0 || result2.errors.every((e) => e.recoverable);
|
|
@@ -113411,8 +113218,14 @@ class PushCommand {
|
|
|
113411
113218
|
try {
|
|
113412
113219
|
await this.blockRegistry.loadBuiltBlocks();
|
|
113413
113220
|
} catch {}
|
|
113414
|
-
const
|
|
113415
|
-
const
|
|
113221
|
+
const config = this.configManager.getConfig();
|
|
113222
|
+
const legacyConfig = this.configManager.getLegacyConfig();
|
|
113223
|
+
let connection;
|
|
113224
|
+
if (this.connectionManager.hasConnection()) {
|
|
113225
|
+
connection = this.connectionManager.getConnection();
|
|
113226
|
+
} else {
|
|
113227
|
+
connection = await this.connectionManager.createConnection(legacyConfig.wordpress);
|
|
113228
|
+
}
|
|
113416
113229
|
const result2 = {
|
|
113417
113230
|
success: false,
|
|
113418
113231
|
operation: {
|
|
@@ -113424,7 +113237,7 @@ class PushCommand {
|
|
|
113424
113237
|
},
|
|
113425
113238
|
target: {
|
|
113426
113239
|
type: "wordpress",
|
|
113427
|
-
identifier:
|
|
113240
|
+
identifier: this.configManager.getWordPressUrl(),
|
|
113428
113241
|
lastModified: new Date
|
|
113429
113242
|
},
|
|
113430
113243
|
timestamp: new Date,
|
|
@@ -113435,7 +113248,7 @@ class PushCommand {
|
|
|
113435
113248
|
conflicts: []
|
|
113436
113249
|
};
|
|
113437
113250
|
try {
|
|
113438
|
-
const mdxFiles = await this.findMDXFiles(options.files,
|
|
113251
|
+
const mdxFiles = await this.findMDXFiles(options.files, config.paths.content);
|
|
113439
113252
|
if (mdxFiles.length === 0) {
|
|
113440
113253
|
result2.operation.status = "completed";
|
|
113441
113254
|
result2.success = true;
|
|
@@ -113463,8 +113276,6 @@ class PushCommand {
|
|
|
113463
113276
|
recoverable: false
|
|
113464
113277
|
});
|
|
113465
113278
|
throw error;
|
|
113466
|
-
} finally {
|
|
113467
|
-
await this.connectionManager.closeConnection();
|
|
113468
113279
|
}
|
|
113469
113280
|
return result2;
|
|
113470
113281
|
}
|
|
@@ -113584,20 +113395,6 @@ ${"=".repeat(80)}`);
|
|
|
113584
113395
|
conflictType: "missing-source"
|
|
113585
113396
|
};
|
|
113586
113397
|
}
|
|
113587
|
-
const wpModified = new Date(wpPost.modified);
|
|
113588
|
-
const lastPushed = mdxFile.frontmatter.lastPushed ? new Date(mdxFile.frontmatter.lastPushed) : null;
|
|
113589
|
-
if (lastPushed && wpModified > lastPushed) {
|
|
113590
|
-
const tolerance = 5000;
|
|
113591
|
-
if (wpModified.getTime() - lastPushed.getTime() > tolerance) {
|
|
113592
|
-
return {
|
|
113593
|
-
postId: mdxFile.frontmatter.postId,
|
|
113594
|
-
localPath: mdxFile.path,
|
|
113595
|
-
wordpressPost: wpPost,
|
|
113596
|
-
localFile: mdxFile,
|
|
113597
|
-
conflictType: "wordpress-newer"
|
|
113598
|
-
};
|
|
113599
|
-
}
|
|
113600
|
-
}
|
|
113601
113398
|
return null;
|
|
113602
113399
|
} catch (error) {
|
|
113603
113400
|
logger.warn(`Could not check for conflicts on post ${mdxFile.frontmatter.postId}: ${error.message}`);
|
|
@@ -113630,31 +113427,15 @@ ${"=".repeat(80)}`);
|
|
|
113630
113427
|
}
|
|
113631
113428
|
let frontmatter = frontmatterMatch[1];
|
|
113632
113429
|
const postId = wpPost.id;
|
|
113633
|
-
|
|
113634
|
-
const lastPushed = new Date().toISOString();
|
|
113635
|
-
if (frontmatter.includes("postId:")) {
|
|
113636
|
-
frontmatter = frontmatter.replace(/postId:\s*\d*/, `postId: ${postId}`);
|
|
113637
|
-
} else {
|
|
113430
|
+
if (!frontmatter.includes("postId:")) {
|
|
113638
113431
|
frontmatter = `${frontmatter}
|
|
113639
113432
|
postId: ${postId}`;
|
|
113640
|
-
|
|
113641
|
-
if (frontmatter.includes("modified:")) {
|
|
113642
|
-
frontmatter = frontmatter.replace(/modified:\s*"[^"]*"/, `modified: "${modified}"`);
|
|
113643
|
-
} else {
|
|
113644
|
-
frontmatter = `${frontmatter}
|
|
113645
|
-
modified: "${modified}"`;
|
|
113646
|
-
}
|
|
113647
|
-
if (frontmatter.includes("lastPushed:")) {
|
|
113648
|
-
frontmatter = frontmatter.replace(/lastPushed:\s*"[^"]*"/, `lastPushed: "${lastPushed}"`);
|
|
113649
|
-
} else {
|
|
113650
|
-
frontmatter = `${frontmatter}
|
|
113651
|
-
lastPushed: "${lastPushed}"`;
|
|
113652
|
-
}
|
|
113653
|
-
const updatedContent = content4.replace(/^---\n([\s\S]*?)\n---/, `---
|
|
113433
|
+
const updatedContent = content4.replace(/^---\n([\s\S]*?)\n---/, `---
|
|
113654
113434
|
${frontmatter}
|
|
113655
113435
|
---`);
|
|
113656
|
-
|
|
113657
|
-
|
|
113436
|
+
fs5.writeFileSync(filePath2, updatedContent, "utf8");
|
|
113437
|
+
logger.debug(`Added postId to ${filePath2}`);
|
|
113438
|
+
}
|
|
113658
113439
|
} catch (error) {
|
|
113659
113440
|
logger.warn(`Failed to update MDX file after push: ${error.message}`);
|
|
113660
113441
|
}
|
|
@@ -113701,6 +113482,15 @@ class ChangeQueue extends EventEmitter3 {
|
|
|
113701
113482
|
});
|
|
113702
113483
|
this.scheduleFlush();
|
|
113703
113484
|
}
|
|
113485
|
+
queueTemplatePartChange(partPath, eventType) {
|
|
113486
|
+
const key = `templatePart:${partPath}`;
|
|
113487
|
+
this.pendingChanges.set(key, {
|
|
113488
|
+
type: "templatePart",
|
|
113489
|
+
filePath: partPath,
|
|
113490
|
+
eventType
|
|
113491
|
+
});
|
|
113492
|
+
this.scheduleFlush();
|
|
113493
|
+
}
|
|
113704
113494
|
queuePageChange(pagePath, eventType) {
|
|
113705
113495
|
const key = `page:${pagePath}`;
|
|
113706
113496
|
this.pendingChanges.set(key, {
|
|
@@ -113733,6 +113523,7 @@ class ChangeQueue extends EventEmitter3 {
|
|
|
113733
113523
|
buildBatch() {
|
|
113734
113524
|
const blocks = new Map;
|
|
113735
113525
|
const templates = [];
|
|
113526
|
+
const templateParts = [];
|
|
113736
113527
|
const pages = [];
|
|
113737
113528
|
const deletedBlocks = [];
|
|
113738
113529
|
for (const change of this.pendingChanges.values()) {
|
|
@@ -113758,6 +113549,11 @@ class ChangeQueue extends EventEmitter3 {
|
|
|
113758
113549
|
templates.push(change.filePath);
|
|
113759
113550
|
}
|
|
113760
113551
|
break;
|
|
113552
|
+
case "templatePart":
|
|
113553
|
+
if (change.eventType !== "unlink") {
|
|
113554
|
+
templateParts.push(change.filePath);
|
|
113555
|
+
}
|
|
113556
|
+
break;
|
|
113761
113557
|
case "page":
|
|
113762
113558
|
if (change.eventType !== "unlink") {
|
|
113763
113559
|
pages.push(change.filePath);
|
|
@@ -113768,6 +113564,7 @@ class ChangeQueue extends EventEmitter3 {
|
|
|
113768
113564
|
return {
|
|
113769
113565
|
blocks,
|
|
113770
113566
|
templates,
|
|
113567
|
+
templateParts,
|
|
113771
113568
|
pages,
|
|
113772
113569
|
deletedBlocks,
|
|
113773
113570
|
triggeredAt: Date.now()
|
|
@@ -114120,10 +113917,16 @@ class DevModeUI {
|
|
|
114120
113917
|
}
|
|
114121
113918
|
}
|
|
114122
113919
|
showWatching() {
|
|
114123
|
-
console.log(
|
|
114124
|
-
|
|
114125
|
-
|
|
114126
|
-
console.log("");
|
|
113920
|
+
console.log(`
|
|
113921
|
+
` + "─".repeat(50));
|
|
113922
|
+
console.log("✅ Dev mode ready! Watching for changes...");
|
|
113923
|
+
console.log("─".repeat(50));
|
|
113924
|
+
console.log(" • Edit blocks → auto-rebuild + cascade updates");
|
|
113925
|
+
console.log(" • Edit templates → auto-rebuild HTML");
|
|
113926
|
+
console.log(" • Edit pages → auto-push to WordPress");
|
|
113927
|
+
console.log(" • Press Ctrl+C to stop");
|
|
113928
|
+
console.log("─".repeat(50) + `
|
|
113929
|
+
`);
|
|
114127
113930
|
}
|
|
114128
113931
|
showInitialBuildStart(blockCount, cached) {
|
|
114129
113932
|
if (cached > 0) {
|
|
@@ -114866,8 +114669,8 @@ var watch = (paths, options) => {
|
|
|
114866
114669
|
var $watch = watch;
|
|
114867
114670
|
|
|
114868
114671
|
// src/dev/dev-mode-orchestrator.ts
|
|
114869
|
-
import * as
|
|
114870
|
-
import * as
|
|
114672
|
+
import * as path17 from "path";
|
|
114673
|
+
import * as fs15 from "fs";
|
|
114871
114674
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
114872
114675
|
|
|
114873
114676
|
// src/build/block-scanner.ts
|
|
@@ -115427,40 +115230,49 @@ import * as fs10 from "fs";
|
|
|
115427
115230
|
import * as path12 from "path";
|
|
115428
115231
|
class DependencyTracker {
|
|
115429
115232
|
blockToTemplates = new Map;
|
|
115233
|
+
blockToTemplateParts = new Map;
|
|
115430
115234
|
blockToPages = new Map;
|
|
115431
115235
|
fileToBlocks = new Map;
|
|
115432
115236
|
blockLocalImports = new Map;
|
|
115433
|
-
async scanDependencies(templatesDir, contentDir) {
|
|
115237
|
+
async scanDependencies(templatesDir, contentDir, templatePartsDir) {
|
|
115434
115238
|
this.blockToTemplates.clear();
|
|
115239
|
+
this.blockToTemplateParts.clear();
|
|
115435
115240
|
this.blockToPages.clear();
|
|
115436
115241
|
this.fileToBlocks.clear();
|
|
115437
115242
|
if (templatesDir && fs10.existsSync(templatesDir)) {
|
|
115438
|
-
await this.
|
|
115243
|
+
await this.scanDirectory(templatesDir, "template");
|
|
115244
|
+
}
|
|
115245
|
+
if (templatePartsDir && fs10.existsSync(templatePartsDir)) {
|
|
115246
|
+
await this.scanDirectory(templatePartsDir, "templatePart");
|
|
115439
115247
|
}
|
|
115440
115248
|
if (fs10.existsSync(contentDir)) {
|
|
115441
115249
|
await this.scanPages(contentDir);
|
|
115442
115250
|
}
|
|
115443
115251
|
const stats = this.getStats();
|
|
115444
|
-
logger.debug(`Dependency scan complete: ${stats.totalTemplates} templates, ${stats.totalPages} pages, ${stats.totalBlocks} unique blocks`);
|
|
115252
|
+
logger.debug(`Dependency scan complete: ${stats.totalTemplates} templates, ${stats.totalTemplateParts} parts, ${stats.totalPages} pages, ${stats.totalBlocks} unique blocks`);
|
|
115445
115253
|
}
|
|
115446
|
-
async
|
|
115447
|
-
const pattern = path12.join(
|
|
115254
|
+
async scanDirectory(dir, type) {
|
|
115255
|
+
const pattern = path12.join(dir, "**/*.mdx");
|
|
115448
115256
|
const files = await glob(pattern);
|
|
115257
|
+
const blockMap = type === "template" ? this.blockToTemplates : this.blockToTemplateParts;
|
|
115449
115258
|
for (const filePath2 of files) {
|
|
115450
115259
|
try {
|
|
115451
115260
|
const blocks = await this.extractBlocksFromFile(filePath2);
|
|
115452
115261
|
this.fileToBlocks.set(filePath2, new Set(blocks));
|
|
115453
115262
|
for (const blockName of blocks) {
|
|
115454
|
-
if (!
|
|
115455
|
-
|
|
115263
|
+
if (!blockMap.has(blockName)) {
|
|
115264
|
+
blockMap.set(blockName, new Set);
|
|
115456
115265
|
}
|
|
115457
|
-
|
|
115266
|
+
blockMap.get(blockName).add(filePath2);
|
|
115458
115267
|
}
|
|
115459
115268
|
} catch (error) {
|
|
115460
|
-
logger.warn(`Failed to scan
|
|
115269
|
+
logger.warn(`Failed to scan ${type} ${filePath2}: ${error}`);
|
|
115461
115270
|
}
|
|
115462
115271
|
}
|
|
115463
|
-
logger.debug(`Scanned ${files.length}
|
|
115272
|
+
logger.debug(`Scanned ${files.length} ${type}s`);
|
|
115273
|
+
}
|
|
115274
|
+
async scanTemplates(templatesDir) {
|
|
115275
|
+
await this.scanDirectory(templatesDir, "template");
|
|
115464
115276
|
}
|
|
115465
115277
|
async scanPages(contentDir) {
|
|
115466
115278
|
const patterns = [
|
|
@@ -115547,12 +115359,16 @@ class DependencyTracker {
|
|
|
115547
115359
|
getDependentTemplates(blockName) {
|
|
115548
115360
|
return Array.from(this.blockToTemplates.get(blockName) || []);
|
|
115549
115361
|
}
|
|
115362
|
+
getDependentTemplateParts(blockName) {
|
|
115363
|
+
return Array.from(this.blockToTemplateParts.get(blockName) || []);
|
|
115364
|
+
}
|
|
115550
115365
|
getDependentPages(blockName) {
|
|
115551
115366
|
return Array.from(this.blockToPages.get(blockName) || []);
|
|
115552
115367
|
}
|
|
115553
115368
|
getDependentFiles(blockName) {
|
|
115554
115369
|
return [
|
|
115555
115370
|
...this.getDependentTemplates(blockName),
|
|
115371
|
+
...this.getDependentTemplateParts(blockName),
|
|
115556
115372
|
...this.getDependentPages(blockName)
|
|
115557
115373
|
];
|
|
115558
115374
|
}
|
|
@@ -115560,16 +115376,21 @@ class DependencyTracker {
|
|
|
115560
115376
|
return Array.from(this.blockLocalImports.get(blockFilePath) || []);
|
|
115561
115377
|
}
|
|
115562
115378
|
hasDependents(blockNames) {
|
|
115563
|
-
return blockNames.some((name2) => (this.blockToTemplates.get(name2)?.size || 0) > 0 || (this.blockToPages.get(name2)?.size || 0) > 0);
|
|
115379
|
+
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
115380
|
}
|
|
115565
115381
|
getCascade(changedBlocks) {
|
|
115566
115382
|
const templates = new Set;
|
|
115383
|
+
const templateParts = new Set;
|
|
115567
115384
|
const pages = new Set;
|
|
115568
115385
|
for (const blockName of changedBlocks) {
|
|
115569
115386
|
const blockTemplates = this.blockToTemplates.get(blockName);
|
|
115570
115387
|
if (blockTemplates) {
|
|
115571
115388
|
blockTemplates.forEach((t) => templates.add(t));
|
|
115572
115389
|
}
|
|
115390
|
+
const blockParts = this.blockToTemplateParts.get(blockName);
|
|
115391
|
+
if (blockParts) {
|
|
115392
|
+
blockParts.forEach((p) => templateParts.add(p));
|
|
115393
|
+
}
|
|
115573
115394
|
const blockPages = this.blockToPages.get(blockName);
|
|
115574
115395
|
if (blockPages) {
|
|
115575
115396
|
blockPages.forEach((p) => pages.add(p));
|
|
@@ -115577,9 +115398,64 @@ class DependencyTracker {
|
|
|
115577
115398
|
}
|
|
115578
115399
|
return {
|
|
115579
115400
|
templates: Array.from(templates),
|
|
115401
|
+
templateParts: Array.from(templateParts),
|
|
115580
115402
|
pages: Array.from(pages)
|
|
115581
115403
|
};
|
|
115582
115404
|
}
|
|
115405
|
+
getCascadeForTypes(changedBlocks, types4) {
|
|
115406
|
+
const result2 = {};
|
|
115407
|
+
for (const type of types4) {
|
|
115408
|
+
result2[type] = [];
|
|
115409
|
+
}
|
|
115410
|
+
for (const blockName of changedBlocks) {
|
|
115411
|
+
if (types4.includes("template")) {
|
|
115412
|
+
const blockTemplates = this.blockToTemplates.get(blockName);
|
|
115413
|
+
if (blockTemplates) {
|
|
115414
|
+
result2.template = [
|
|
115415
|
+
...new Set([
|
|
115416
|
+
...result2.template || [],
|
|
115417
|
+
...Array.from(blockTemplates)
|
|
115418
|
+
])
|
|
115419
|
+
];
|
|
115420
|
+
}
|
|
115421
|
+
}
|
|
115422
|
+
if (types4.includes("templatePart")) {
|
|
115423
|
+
const blockParts = this.blockToTemplateParts.get(blockName);
|
|
115424
|
+
if (blockParts) {
|
|
115425
|
+
result2.templatePart = [
|
|
115426
|
+
...new Set([
|
|
115427
|
+
...result2.templatePart || [],
|
|
115428
|
+
...Array.from(blockParts)
|
|
115429
|
+
])
|
|
115430
|
+
];
|
|
115431
|
+
}
|
|
115432
|
+
}
|
|
115433
|
+
if (types4.includes("page")) {
|
|
115434
|
+
const blockPages = this.blockToPages.get(blockName);
|
|
115435
|
+
if (blockPages) {
|
|
115436
|
+
result2.page = [
|
|
115437
|
+
...new Set([...result2.page || [], ...Array.from(blockPages)])
|
|
115438
|
+
];
|
|
115439
|
+
}
|
|
115440
|
+
}
|
|
115441
|
+
}
|
|
115442
|
+
return result2;
|
|
115443
|
+
}
|
|
115444
|
+
getAffectedArtifactTypes(changedBlocks) {
|
|
115445
|
+
const types4 = [];
|
|
115446
|
+
for (const blockName of changedBlocks) {
|
|
115447
|
+
if (!types4.includes("template") && (this.blockToTemplates.get(blockName)?.size || 0) > 0) {
|
|
115448
|
+
types4.push("template");
|
|
115449
|
+
}
|
|
115450
|
+
if (!types4.includes("templatePart") && (this.blockToTemplateParts.get(blockName)?.size || 0) > 0) {
|
|
115451
|
+
types4.push("templatePart");
|
|
115452
|
+
}
|
|
115453
|
+
if (!types4.includes("page") && (this.blockToPages.get(blockName)?.size || 0) > 0) {
|
|
115454
|
+
types4.push("page");
|
|
115455
|
+
}
|
|
115456
|
+
}
|
|
115457
|
+
return types4;
|
|
115458
|
+
}
|
|
115583
115459
|
findBlockForImport(importPath) {
|
|
115584
115460
|
for (const [blockPath, imports] of this.blockLocalImports) {
|
|
115585
115461
|
if (imports.has(importPath)) {
|
|
@@ -115594,6 +115470,8 @@ class DependencyTracker {
|
|
|
115594
115470
|
for (const blockName of oldBlocks) {
|
|
115595
115471
|
if (type === "template") {
|
|
115596
115472
|
this.blockToTemplates.get(blockName)?.delete(filePath2);
|
|
115473
|
+
} else if (type === "templatePart") {
|
|
115474
|
+
this.blockToTemplateParts.get(blockName)?.delete(filePath2);
|
|
115597
115475
|
} else {
|
|
115598
115476
|
this.blockToPages.get(blockName)?.delete(filePath2);
|
|
115599
115477
|
}
|
|
@@ -115608,6 +115486,11 @@ class DependencyTracker {
|
|
|
115608
115486
|
this.blockToTemplates.set(blockName, new Set);
|
|
115609
115487
|
}
|
|
115610
115488
|
this.blockToTemplates.get(blockName).add(filePath2);
|
|
115489
|
+
} else if (type === "templatePart") {
|
|
115490
|
+
if (!this.blockToTemplateParts.has(blockName)) {
|
|
115491
|
+
this.blockToTemplateParts.set(blockName, new Set);
|
|
115492
|
+
}
|
|
115493
|
+
this.blockToTemplateParts.get(blockName).add(filePath2);
|
|
115611
115494
|
} else {
|
|
115612
115495
|
if (!this.blockToPages.has(blockName)) {
|
|
115613
115496
|
this.blockToPages.set(blockName, new Set);
|
|
@@ -115624,6 +115507,7 @@ class DependencyTracker {
|
|
|
115624
115507
|
if (blocks) {
|
|
115625
115508
|
for (const blockName of blocks) {
|
|
115626
115509
|
this.blockToTemplates.get(blockName)?.delete(filePath2);
|
|
115510
|
+
this.blockToTemplateParts.get(blockName)?.delete(filePath2);
|
|
115627
115511
|
this.blockToPages.get(blockName)?.delete(filePath2);
|
|
115628
115512
|
}
|
|
115629
115513
|
}
|
|
@@ -115637,23 +115521,33 @@ class DependencyTracker {
|
|
|
115637
115521
|
if (templates.size > 0)
|
|
115638
115522
|
blocksWithDependents++;
|
|
115639
115523
|
}
|
|
115524
|
+
for (const [blockName, parts] of this.blockToTemplateParts) {
|
|
115525
|
+
allBlocks.add(blockName);
|
|
115526
|
+
if (parts.size > 0 && !this.blockToTemplates.get(blockName)?.size) {
|
|
115527
|
+
blocksWithDependents++;
|
|
115528
|
+
}
|
|
115529
|
+
}
|
|
115640
115530
|
for (const [blockName, pages] of this.blockToPages) {
|
|
115641
115531
|
allBlocks.add(blockName);
|
|
115642
|
-
if (pages.size > 0 && !this.blockToTemplates.get(blockName)?.size) {
|
|
115532
|
+
if (pages.size > 0 && !this.blockToTemplates.get(blockName)?.size && !this.blockToTemplateParts.get(blockName)?.size) {
|
|
115643
115533
|
blocksWithDependents++;
|
|
115644
115534
|
}
|
|
115645
115535
|
}
|
|
115646
115536
|
let totalTemplates = 0;
|
|
115537
|
+
let totalTemplateParts = 0;
|
|
115647
115538
|
let totalPages = 0;
|
|
115648
115539
|
for (const filePath2 of this.fileToBlocks.keys()) {
|
|
115649
115540
|
if (filePath2.includes("/templates/") || filePath2.includes("\\templates\\")) {
|
|
115650
115541
|
totalTemplates++;
|
|
115542
|
+
} else if (filePath2.includes("/parts/") || filePath2.includes("\\parts\\")) {
|
|
115543
|
+
totalTemplateParts++;
|
|
115651
115544
|
} else {
|
|
115652
115545
|
totalPages++;
|
|
115653
115546
|
}
|
|
115654
115547
|
}
|
|
115655
115548
|
return {
|
|
115656
115549
|
totalTemplates,
|
|
115550
|
+
totalTemplateParts,
|
|
115657
115551
|
totalPages,
|
|
115658
115552
|
totalBlocks: allBlocks.size,
|
|
115659
115553
|
blocksWithDependents
|
|
@@ -115668,6 +115562,14 @@ class DependencyTracker {
|
|
|
115668
115562
|
}
|
|
115669
115563
|
}
|
|
115670
115564
|
logger.info(`
|
|
115565
|
+
=== Block → Template Parts ===`);
|
|
115566
|
+
for (const [blockName, parts] of this.blockToTemplateParts) {
|
|
115567
|
+
if (parts.size > 0) {
|
|
115568
|
+
const names = Array.from(parts).map((p) => path12.basename(p));
|
|
115569
|
+
logger.info(`${blockName}: [${names.join(", ")}]`);
|
|
115570
|
+
}
|
|
115571
|
+
}
|
|
115572
|
+
logger.info(`
|
|
115671
115573
|
=== Block → Pages ===`);
|
|
115672
115574
|
for (const [blockName, pages] of this.blockToPages) {
|
|
115673
115575
|
if (pages.size > 0) {
|
|
@@ -115679,6 +115581,7 @@ class DependencyTracker {
|
|
|
115679
115581
|
logger.info(`
|
|
115680
115582
|
=== Stats ===`);
|
|
115681
115583
|
logger.info(`Templates: ${stats.totalTemplates}`);
|
|
115584
|
+
logger.info(`Template Parts: ${stats.totalTemplateParts}`);
|
|
115682
115585
|
logger.info(`Pages: ${stats.totalPages}`);
|
|
115683
115586
|
logger.info(`Unique blocks: ${stats.totalBlocks}`);
|
|
115684
115587
|
logger.info(`Blocks with dependents: ${stats.blocksWithDependents}`);
|
|
@@ -116006,10 +115909,359 @@ add_action('enqueue_block_assets', 'wordpress_flow_enqueue_block_scripts');
|
|
|
116006
115909
|
);`;
|
|
116007
115910
|
}
|
|
116008
115911
|
}
|
|
115912
|
+
|
|
115913
|
+
// src/env/docker-env-manager.ts
|
|
115914
|
+
import { execSync } from "child_process";
|
|
115915
|
+
import * as fs14 from "fs";
|
|
115916
|
+
import * as path16 from "path";
|
|
115917
|
+
class DockerEnvManager {
|
|
115918
|
+
projectName;
|
|
115919
|
+
workspaceDir;
|
|
115920
|
+
config;
|
|
115921
|
+
containerNames;
|
|
115922
|
+
constructor(options) {
|
|
115923
|
+
this.projectName = this.sanitizeProjectName(options.projectName);
|
|
115924
|
+
this.workspaceDir = options.workspaceDir;
|
|
115925
|
+
this.config = options.config;
|
|
115926
|
+
this.containerNames = {
|
|
115927
|
+
wordpress: `${this.projectName}-wordpress`,
|
|
115928
|
+
mysql: `${this.projectName}-mysql`
|
|
115929
|
+
};
|
|
115930
|
+
}
|
|
115931
|
+
sanitizeProjectName(name2) {
|
|
115932
|
+
return name2.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
115933
|
+
}
|
|
115934
|
+
async checkDocker() {
|
|
115935
|
+
try {
|
|
115936
|
+
execSync("docker info", { stdio: "pipe" });
|
|
115937
|
+
return true;
|
|
115938
|
+
} catch {
|
|
115939
|
+
return false;
|
|
115940
|
+
}
|
|
115941
|
+
}
|
|
115942
|
+
async getContainerStatus() {
|
|
115943
|
+
const status = {
|
|
115944
|
+
wordpress: "not-found",
|
|
115945
|
+
mysql: "not-found"
|
|
115946
|
+
};
|
|
115947
|
+
try {
|
|
115948
|
+
const wpStatus = execSync(`docker inspect -f '{{.State.Status}}' ${this.containerNames.wordpress} 2>/dev/null`, { encoding: "utf8" }).trim();
|
|
115949
|
+
status.wordpress = wpStatus === "running" ? "running" : "stopped";
|
|
115950
|
+
} catch {
|
|
115951
|
+
status.wordpress = "not-found";
|
|
115952
|
+
}
|
|
115953
|
+
try {
|
|
115954
|
+
const mysqlStatus = execSync(`docker inspect -f '{{.State.Status}}' ${this.containerNames.mysql} 2>/dev/null`, { encoding: "utf8" }).trim();
|
|
115955
|
+
status.mysql = mysqlStatus === "running" ? "running" : "stopped";
|
|
115956
|
+
} catch {
|
|
115957
|
+
status.mysql = "not-found";
|
|
115958
|
+
}
|
|
115959
|
+
return status;
|
|
115960
|
+
}
|
|
115961
|
+
async start() {
|
|
115962
|
+
const dockerInstalled = await this.checkDocker();
|
|
115963
|
+
if (!dockerInstalled) {
|
|
115964
|
+
throw new Error(`Docker is not installed or not running.
|
|
115965
|
+
|
|
115966
|
+
` + `To install Docker:
|
|
115967
|
+
` + ` • macOS: Download from https://docker.com/products/docker-desktop
|
|
115968
|
+
` + " • Linux: Run `curl -fsSL https://get.docker.com | sh`\n" + ` • Windows: Download from https://docker.com/products/docker-desktop
|
|
115969
|
+
|
|
115970
|
+
` + "After installing, make sure Docker Desktop is running.");
|
|
115971
|
+
}
|
|
115972
|
+
const status = await this.getContainerStatus();
|
|
115973
|
+
let isFirstRun = false;
|
|
115974
|
+
if (status.wordpress === "not-found" || status.mysql === "not-found") {
|
|
115975
|
+
logger.info("\uD83D\uDC33 Creating Docker containers...");
|
|
115976
|
+
await this.createContainers();
|
|
115977
|
+
isFirstRun = true;
|
|
115978
|
+
} else if (status.wordpress === "stopped" || status.mysql === "stopped") {
|
|
115979
|
+
logger.info("\uD83D\uDC33 Starting existing containers...");
|
|
115980
|
+
await this.startContainers();
|
|
115981
|
+
} else {
|
|
115982
|
+
logger.info("\uD83D\uDC33 Docker containers already running");
|
|
115983
|
+
}
|
|
115984
|
+
await this.waitForWordPress();
|
|
115985
|
+
const wordpressUrl = this.getWordPressUrl();
|
|
115986
|
+
return { wordpressUrl, isFirstRun };
|
|
115987
|
+
}
|
|
115988
|
+
async createContainers() {
|
|
115989
|
+
try {
|
|
115990
|
+
execSync(`docker network create ${this.projectName}-network 2>/dev/null`, {
|
|
115991
|
+
stdio: "pipe"
|
|
115992
|
+
});
|
|
115993
|
+
} catch {}
|
|
115994
|
+
const themeDir = path16.resolve(this.workspaceDir, this.config.paths.theme);
|
|
115995
|
+
const themeName = path16.basename(themeDir);
|
|
115996
|
+
logger.info(" Starting MySQL...");
|
|
115997
|
+
const mysqlVolume = `-v ${this.projectName}-mysql-data:/var/lib/mysql`;
|
|
115998
|
+
const mysqlPort = this.config.dev.databasePort ? `-p ${this.config.dev.databasePort}:3306` : "";
|
|
115999
|
+
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" });
|
|
116000
|
+
await this.waitForMySQL();
|
|
116001
|
+
logger.info(" Starting WordPress...");
|
|
116002
|
+
const uploadsVolume = `-v ${this.projectName}-uploads:/var/www/html/wp-content/uploads`;
|
|
116003
|
+
let pluginMounts = "";
|
|
116004
|
+
const pluginsDir = path16.resolve(this.workspaceDir, this.config.paths.plugins);
|
|
116005
|
+
if (fs14.existsSync(pluginsDir)) {
|
|
116006
|
+
const pluginFolders = fs14.readdirSync(pluginsDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
|
|
116007
|
+
for (const pluginName of pluginFolders) {
|
|
116008
|
+
const pluginPath = path16.join(pluginsDir, pluginName);
|
|
116009
|
+
pluginMounts += ` -v "${pluginPath}:/var/www/html/wp-content/plugins/${pluginName}"`;
|
|
116010
|
+
}
|
|
116011
|
+
if (pluginFolders.length > 0) {
|
|
116012
|
+
logger.info(` Mounting ${pluginFolders.length} local plugin(s): ${pluginFolders.join(", ")}`);
|
|
116013
|
+
}
|
|
116014
|
+
}
|
|
116015
|
+
const wpImage = this.config.dev.wordpressVersion === "latest" ? `wordpress:php${this.config.dev.phpVersion}` : `wordpress:${this.config.dev.wordpressVersion}-php${this.config.dev.phpVersion}`;
|
|
116016
|
+
execSync(`docker run -d --name ${this.containerNames.wordpress} --network ${this.projectName}-network -p ${this.config.dev.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" });
|
|
116017
|
+
}
|
|
116018
|
+
async startContainers() {
|
|
116019
|
+
execSync(`docker start ${this.containerNames.mysql}`, { stdio: "pipe" });
|
|
116020
|
+
await this.waitForMySQL();
|
|
116021
|
+
execSync(`docker start ${this.containerNames.wordpress}`, {
|
|
116022
|
+
stdio: "pipe"
|
|
116023
|
+
});
|
|
116024
|
+
}
|
|
116025
|
+
async stop() {
|
|
116026
|
+
logger.info("\uD83D\uDC33 Stopping Docker containers...");
|
|
116027
|
+
try {
|
|
116028
|
+
execSync(`docker stop ${this.containerNames.wordpress}`, {
|
|
116029
|
+
stdio: "pipe"
|
|
116030
|
+
});
|
|
116031
|
+
} catch {}
|
|
116032
|
+
try {
|
|
116033
|
+
execSync(`docker stop ${this.containerNames.mysql}`, { stdio: "pipe" });
|
|
116034
|
+
} catch {}
|
|
116035
|
+
}
|
|
116036
|
+
async waitForMySQL() {
|
|
116037
|
+
const maxAttempts = 30;
|
|
116038
|
+
let attempts = 0;
|
|
116039
|
+
while (attempts < maxAttempts) {
|
|
116040
|
+
try {
|
|
116041
|
+
execSync(`docker exec ${this.containerNames.mysql} mysqladmin ping -h localhost -u root -ppassword 2>/dev/null`, { stdio: "pipe" });
|
|
116042
|
+
return;
|
|
116043
|
+
} catch {
|
|
116044
|
+
attempts++;
|
|
116045
|
+
await this.sleep(1000);
|
|
116046
|
+
}
|
|
116047
|
+
}
|
|
116048
|
+
throw new Error("MySQL failed to start within 30 seconds");
|
|
116049
|
+
}
|
|
116050
|
+
async waitForMySQLReady() {
|
|
116051
|
+
const maxAttempts = 30;
|
|
116052
|
+
let attempts = 0;
|
|
116053
|
+
while (attempts < maxAttempts) {
|
|
116054
|
+
try {
|
|
116055
|
+
execSync(`docker exec ${this.containerNames.mysql} mysql -h 127.0.0.1 -u wordpress -pwordpress -e "SELECT 1" 2>/dev/null`, { stdio: "pipe" });
|
|
116056
|
+
return;
|
|
116057
|
+
} catch {
|
|
116058
|
+
attempts++;
|
|
116059
|
+
await this.sleep(1000);
|
|
116060
|
+
}
|
|
116061
|
+
}
|
|
116062
|
+
throw new Error("MySQL failed to accept connections within 30 seconds");
|
|
116063
|
+
}
|
|
116064
|
+
async waitForWordPress() {
|
|
116065
|
+
const maxAttempts = 60;
|
|
116066
|
+
let attempts = 0;
|
|
116067
|
+
logger.info(" Waiting for WordPress...");
|
|
116068
|
+
while (attempts < maxAttempts) {
|
|
116069
|
+
try {
|
|
116070
|
+
const response = execSync(`curl -s -o /dev/null -w "%{http_code}" http://localhost:${this.config.dev.port}`, { encoding: "utf8", stdio: "pipe" }).trim();
|
|
116071
|
+
if (response.length > 0) {
|
|
116072
|
+
return;
|
|
116073
|
+
}
|
|
116074
|
+
} catch {}
|
|
116075
|
+
attempts++;
|
|
116076
|
+
await this.sleep(1000);
|
|
116077
|
+
}
|
|
116078
|
+
throw new Error("WordPress failed to start within 60 seconds");
|
|
116079
|
+
}
|
|
116080
|
+
async installWPCLI() {
|
|
116081
|
+
logger.info(" Installing WP-CLI...");
|
|
116082
|
+
try {
|
|
116083
|
+
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" });
|
|
116084
|
+
} catch (error) {
|
|
116085
|
+
throw new Error(`Failed to install WP-CLI: ${error.message}`);
|
|
116086
|
+
}
|
|
116087
|
+
}
|
|
116088
|
+
async hasWPCLI() {
|
|
116089
|
+
try {
|
|
116090
|
+
execSync(`docker exec ${this.containerNames.wordpress} wp --version --allow-root 2>/dev/null`, { stdio: "pipe" });
|
|
116091
|
+
return true;
|
|
116092
|
+
} catch {
|
|
116093
|
+
return false;
|
|
116094
|
+
}
|
|
116095
|
+
}
|
|
116096
|
+
async isWordPressInstalled() {
|
|
116097
|
+
if (!await this.hasWPCLI()) {
|
|
116098
|
+
await this.installWPCLI();
|
|
116099
|
+
}
|
|
116100
|
+
try {
|
|
116101
|
+
execSync(`docker exec ${this.containerNames.wordpress} wp core is-installed --allow-root 2>/dev/null`, { stdio: "pipe", encoding: "utf8" });
|
|
116102
|
+
return true;
|
|
116103
|
+
} catch {
|
|
116104
|
+
return false;
|
|
116105
|
+
}
|
|
116106
|
+
}
|
|
116107
|
+
async installWordPress() {
|
|
116108
|
+
logger.info(" Installing WordPress...");
|
|
116109
|
+
const siteUrl = this.getWordPressUrl();
|
|
116110
|
+
const themeName = path16.basename(path16.resolve(this.workspaceDir, this.config.paths.theme));
|
|
116111
|
+
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" });
|
|
116112
|
+
logger.info(` Activating theme: ${themeName}...`);
|
|
116113
|
+
try {
|
|
116114
|
+
execSync(`docker exec ${this.containerNames.wordpress} wp theme activate ${themeName} --allow-root`, { stdio: "pipe" });
|
|
116115
|
+
} catch (error) {
|
|
116116
|
+
logger.warn(` Could not activate theme: ${themeName}`);
|
|
116117
|
+
}
|
|
116118
|
+
execSync(`docker exec ${this.containerNames.wordpress} wp rewrite structure '/%postname%/' --allow-root`, { stdio: "pipe" });
|
|
116119
|
+
}
|
|
116120
|
+
async installPlugins() {
|
|
116121
|
+
if (this.config.dev.plugins.length === 0)
|
|
116122
|
+
return;
|
|
116123
|
+
logger.info(" Installing plugins...");
|
|
116124
|
+
for (const plugin of this.config.dev.plugins) {
|
|
116125
|
+
try {
|
|
116126
|
+
if (plugin.startsWith("./") || plugin.startsWith("/")) {
|
|
116127
|
+
const pluginPath = path16.resolve(this.workspaceDir, plugin);
|
|
116128
|
+
const pluginName = path16.basename(pluginPath);
|
|
116129
|
+
execSync(`docker cp "${pluginPath}" ${this.containerNames.wordpress}:/var/www/html/wp-content/plugins/${pluginName}`, { stdio: "pipe" });
|
|
116130
|
+
execSync(`docker exec ${this.containerNames.wordpress} wp plugin activate ${pluginName} --allow-root`, { stdio: "pipe" });
|
|
116131
|
+
} else {
|
|
116132
|
+
execSync(`docker exec ${this.containerNames.wordpress} wp plugin install ${plugin} --activate --allow-root`, { stdio: "pipe" });
|
|
116133
|
+
}
|
|
116134
|
+
logger.info(` ✓ ${plugin}`);
|
|
116135
|
+
} catch (error) {
|
|
116136
|
+
logger.warn(` ✗ Failed to install: ${plugin}`);
|
|
116137
|
+
}
|
|
116138
|
+
}
|
|
116139
|
+
}
|
|
116140
|
+
async importSqlDump() {
|
|
116141
|
+
if (!this.config.dev.sqlDump)
|
|
116142
|
+
return;
|
|
116143
|
+
const sqlPath = path16.resolve(this.workspaceDir, this.config.dev.sqlDump);
|
|
116144
|
+
if (!fs14.existsSync(sqlPath)) {
|
|
116145
|
+
logger.warn(` SQL dump not found: ${sqlPath}`);
|
|
116146
|
+
return;
|
|
116147
|
+
}
|
|
116148
|
+
logger.info(" Importing SQL dump...");
|
|
116149
|
+
await this.waitForMySQLReady();
|
|
116150
|
+
execSync(`docker cp "${sqlPath}" ${this.containerNames.mysql}:/tmp/dump.sql`, { stdio: "pipe" });
|
|
116151
|
+
execSync(`docker exec ${this.containerNames.mysql} sh -c "mysql -h 127.0.0.1 -u wordpress -pwordpress wordpress < /tmp/dump.sql"`, { stdio: "pipe" });
|
|
116152
|
+
const siteUrl = this.getWordPressUrl();
|
|
116153
|
+
execSync(`docker exec ${this.containerNames.wordpress} wp option update siteurl "${siteUrl}" --allow-root`, { stdio: "pipe" });
|
|
116154
|
+
execSync(`docker exec ${this.containerNames.wordpress} wp option update home "${siteUrl}" --allow-root`, { stdio: "pipe" });
|
|
116155
|
+
await this.reactivatePlugins();
|
|
116156
|
+
logger.info(" ✓ SQL dump imported");
|
|
116157
|
+
}
|
|
116158
|
+
async reactivatePlugins() {
|
|
116159
|
+
try {
|
|
116160
|
+
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();
|
|
116161
|
+
if (!pluginsOutput)
|
|
116162
|
+
return;
|
|
116163
|
+
const inactivePlugins = pluginsOutput.split(`
|
|
116164
|
+
`).filter((p) => p.trim());
|
|
116165
|
+
if (inactivePlugins.length === 0)
|
|
116166
|
+
return;
|
|
116167
|
+
logger.info(" Reactivating plugins...");
|
|
116168
|
+
for (const plugin of inactivePlugins) {
|
|
116169
|
+
try {
|
|
116170
|
+
execSync(`docker exec ${this.containerNames.wordpress} wp plugin activate ${plugin} --allow-root`, { stdio: "pipe" });
|
|
116171
|
+
logger.info(` ✓ ${plugin}`);
|
|
116172
|
+
} catch {
|
|
116173
|
+
logger.warn(` ✗ Could not activate: ${plugin}`);
|
|
116174
|
+
}
|
|
116175
|
+
}
|
|
116176
|
+
} catch {}
|
|
116177
|
+
}
|
|
116178
|
+
async exportSqlDump(outputPath) {
|
|
116179
|
+
const status = await this.getContainerStatus();
|
|
116180
|
+
if (status.mysql !== "running") {
|
|
116181
|
+
throw new Error("MySQL container is not running. Start the environment first with `wordpress-flow dev`");
|
|
116182
|
+
}
|
|
116183
|
+
logger.info(" Exporting database...");
|
|
116184
|
+
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 });
|
|
116185
|
+
const resolvedPath = path16.resolve(this.workspaceDir, outputPath);
|
|
116186
|
+
const dir = path16.dirname(resolvedPath);
|
|
116187
|
+
if (!fs14.existsSync(dir)) {
|
|
116188
|
+
fs14.mkdirSync(dir, { recursive: true });
|
|
116189
|
+
}
|
|
116190
|
+
fs14.writeFileSync(resolvedPath, sqlContent, "utf8");
|
|
116191
|
+
logger.info(` ✓ Database exported to ${outputPath}`);
|
|
116192
|
+
}
|
|
116193
|
+
async importSqlDumpFromFile(inputPath) {
|
|
116194
|
+
const status = await this.getContainerStatus();
|
|
116195
|
+
if (status.mysql !== "running") {
|
|
116196
|
+
throw new Error("MySQL container is not running. Start the environment first with `wordpress-flow dev`");
|
|
116197
|
+
}
|
|
116198
|
+
const sqlPath = path16.resolve(this.workspaceDir, inputPath);
|
|
116199
|
+
if (!fs14.existsSync(sqlPath)) {
|
|
116200
|
+
throw new Error(`SQL dump not found: ${sqlPath}`);
|
|
116201
|
+
}
|
|
116202
|
+
logger.info(" Importing SQL dump...");
|
|
116203
|
+
await this.waitForMySQLReady();
|
|
116204
|
+
execSync(`docker cp "${sqlPath}" ${this.containerNames.mysql}:/tmp/dump.sql`, { stdio: "pipe" });
|
|
116205
|
+
execSync(`docker exec ${this.containerNames.mysql} sh -c "mysql -h 127.0.0.1 -u wordpress -pwordpress wordpress < /tmp/dump.sql"`, { stdio: "pipe" });
|
|
116206
|
+
if (!await this.hasWPCLI()) {
|
|
116207
|
+
await this.installWPCLI();
|
|
116208
|
+
}
|
|
116209
|
+
const siteUrl = this.getWordPressUrl();
|
|
116210
|
+
try {
|
|
116211
|
+
execSync(`docker exec ${this.containerNames.wordpress} wp option update siteurl "${siteUrl}" --allow-root`, { stdio: "pipe" });
|
|
116212
|
+
execSync(`docker exec ${this.containerNames.wordpress} wp option update home "${siteUrl}" --allow-root`, { stdio: "pipe" });
|
|
116213
|
+
} catch {
|
|
116214
|
+
logger.warn(" Could not update site URLs (WordPress may not be fully installed)");
|
|
116215
|
+
}
|
|
116216
|
+
logger.info(" ✓ SQL dump imported");
|
|
116217
|
+
}
|
|
116218
|
+
getDatabaseConfig() {
|
|
116219
|
+
return {
|
|
116220
|
+
host: "127.0.0.1",
|
|
116221
|
+
port: this.config.dev.databasePort,
|
|
116222
|
+
database: "wordpress",
|
|
116223
|
+
username: "wordpress",
|
|
116224
|
+
password: "wordpress"
|
|
116225
|
+
};
|
|
116226
|
+
}
|
|
116227
|
+
getWordPressUrl() {
|
|
116228
|
+
return `http://localhost:${this.config.dev.port}`;
|
|
116229
|
+
}
|
|
116230
|
+
sleep(ms) {
|
|
116231
|
+
return new Promise((resolve6) => setTimeout(resolve6, ms));
|
|
116232
|
+
}
|
|
116233
|
+
async cleanup() {
|
|
116234
|
+
logger.info("\uD83E\uDDF9 Cleaning up Docker environment...");
|
|
116235
|
+
try {
|
|
116236
|
+
execSync(`docker rm -f ${this.containerNames.wordpress}`, {
|
|
116237
|
+
stdio: "pipe"
|
|
116238
|
+
});
|
|
116239
|
+
} catch {}
|
|
116240
|
+
try {
|
|
116241
|
+
execSync(`docker rm -f ${this.containerNames.mysql}`, { stdio: "pipe" });
|
|
116242
|
+
} catch {}
|
|
116243
|
+
try {
|
|
116244
|
+
execSync(`docker network rm ${this.projectName}-network`, {
|
|
116245
|
+
stdio: "pipe"
|
|
116246
|
+
});
|
|
116247
|
+
} catch {}
|
|
116248
|
+
try {
|
|
116249
|
+
execSync(`docker volume rm ${this.projectName}-mysql-data`, {
|
|
116250
|
+
stdio: "pipe"
|
|
116251
|
+
});
|
|
116252
|
+
} catch {}
|
|
116253
|
+
try {
|
|
116254
|
+
execSync(`docker volume rm ${this.projectName}-uploads`, {
|
|
116255
|
+
stdio: "pipe"
|
|
116256
|
+
});
|
|
116257
|
+
} catch {}
|
|
116258
|
+
logger.info(" ✓ Cleanup complete");
|
|
116259
|
+
}
|
|
116260
|
+
}
|
|
116009
116261
|
// package.json
|
|
116010
116262
|
var package_default = {
|
|
116011
116263
|
name: "@wordpress-flow/cli",
|
|
116012
|
-
version: "1.
|
|
116264
|
+
version: "1.2.0",
|
|
116013
116265
|
type: "module",
|
|
116014
116266
|
description: "TypeScript-based WordPress block creation system",
|
|
116015
116267
|
main: "dist/index.js",
|
|
@@ -116062,7 +116314,7 @@ var package_default = {
|
|
|
116062
116314
|
|
|
116063
116315
|
// src/dev/dev-mode-orchestrator.ts
|
|
116064
116316
|
var __filename2 = fileURLToPath4(import.meta.url);
|
|
116065
|
-
var __dirname2 =
|
|
116317
|
+
var __dirname2 = path17.dirname(__filename2);
|
|
116066
116318
|
|
|
116067
116319
|
class DevModeOrchestrator {
|
|
116068
116320
|
configManager;
|
|
@@ -116080,6 +116332,7 @@ class DevModeOrchestrator {
|
|
|
116080
116332
|
phpGenerator;
|
|
116081
116333
|
blockRegistry;
|
|
116082
116334
|
pushCommand;
|
|
116335
|
+
dockerEnvManager;
|
|
116083
116336
|
options;
|
|
116084
116337
|
watchers = [];
|
|
116085
116338
|
isRunning = false;
|
|
@@ -116087,6 +116340,8 @@ class DevModeOrchestrator {
|
|
|
116087
116340
|
outputDir;
|
|
116088
116341
|
templatesDir;
|
|
116089
116342
|
templatesOutputDir;
|
|
116343
|
+
templatePartsDir;
|
|
116344
|
+
templatePartsOutputDir;
|
|
116090
116345
|
contentDir;
|
|
116091
116346
|
webpackConfig;
|
|
116092
116347
|
scriptsPath;
|
|
@@ -116102,6 +116357,7 @@ class DevModeOrchestrator {
|
|
|
116102
116357
|
autoPush: true,
|
|
116103
116358
|
buildTemplates: true,
|
|
116104
116359
|
verbose: false,
|
|
116360
|
+
skipEnv: false,
|
|
116105
116361
|
...options
|
|
116106
116362
|
};
|
|
116107
116363
|
this.configManager = ConfigManager.getInstance();
|
|
@@ -116122,16 +116378,30 @@ class DevModeOrchestrator {
|
|
|
116122
116378
|
});
|
|
116123
116379
|
}
|
|
116124
116380
|
async start() {
|
|
116125
|
-
|
|
116381
|
+
console.log(`
|
|
116382
|
+
\uD83D\uDE80 Starting dev mode...
|
|
116383
|
+
`);
|
|
116126
116384
|
try {
|
|
116385
|
+
console.log("\uD83D\uDCCB Loading configuration...");
|
|
116127
116386
|
await this.initializeConfig();
|
|
116387
|
+
const config = this.configManager.getConfig();
|
|
116388
|
+
if (!this.options.skipEnv) {
|
|
116389
|
+
console.log("\uD83D\uDC33 Setting up Docker environment...");
|
|
116390
|
+
await this.startDockerEnvironment();
|
|
116391
|
+
}
|
|
116392
|
+
console.log("⚙️ Initializing build system...");
|
|
116128
116393
|
this.initializeManagers();
|
|
116129
116394
|
if (this.options.autoPush) {
|
|
116395
|
+
console.log("\uD83D\uDD0C Connecting to WordPress...");
|
|
116130
116396
|
await this.connectWordPress();
|
|
116131
116397
|
}
|
|
116398
|
+
console.log("\uD83D\uDD0D Scanning blocks...");
|
|
116132
116399
|
const blocks = await this.scanBlocks();
|
|
116400
|
+
console.log("\uD83D\uDD17 Analyzing dependencies...");
|
|
116133
116401
|
await this.scanDependencies();
|
|
116402
|
+
console.log("\uD83D\uDD28 Running initial build...");
|
|
116134
116403
|
await this.performInitialBuild(blocks);
|
|
116404
|
+
console.log("\uD83D\uDC40 Starting file watchers...");
|
|
116135
116405
|
this.startWatchers();
|
|
116136
116406
|
this.isRunning = true;
|
|
116137
116407
|
this.ui.showWatching();
|
|
@@ -116142,23 +116412,62 @@ class DevModeOrchestrator {
|
|
|
116142
116412
|
throw error;
|
|
116143
116413
|
}
|
|
116144
116414
|
}
|
|
116145
|
-
async
|
|
116146
|
-
const
|
|
116147
|
-
|
|
116148
|
-
|
|
116149
|
-
if (
|
|
116150
|
-
|
|
116151
|
-
|
|
116152
|
-
|
|
116415
|
+
async startDockerEnvironment() {
|
|
116416
|
+
const config = this.configManager.getConfig();
|
|
116417
|
+
const packageJsonPath = path17.join(this.configManager.getConfigDir(), "package.json");
|
|
116418
|
+
let projectName = "wordpress-project";
|
|
116419
|
+
if (fs15.existsSync(packageJsonPath)) {
|
|
116420
|
+
try {
|
|
116421
|
+
const pkg = JSON.parse(fs15.readFileSync(packageJsonPath, "utf8"));
|
|
116422
|
+
projectName = pkg.name || projectName;
|
|
116423
|
+
} catch {}
|
|
116153
116424
|
}
|
|
116154
|
-
this.
|
|
116155
|
-
|
|
116156
|
-
|
|
116157
|
-
|
|
116158
|
-
|
|
116425
|
+
this.dockerEnvManager = new DockerEnvManager({
|
|
116426
|
+
projectName,
|
|
116427
|
+
workspaceDir: this.configManager.getConfigDir(),
|
|
116428
|
+
config
|
|
116429
|
+
});
|
|
116430
|
+
try {
|
|
116431
|
+
const { wordpressUrl, isFirstRun } = await this.dockerEnvManager.start();
|
|
116432
|
+
if (isFirstRun) {
|
|
116433
|
+
const isInstalled = await this.dockerEnvManager.isWordPressInstalled();
|
|
116434
|
+
if (!isInstalled) {
|
|
116435
|
+
await this.dockerEnvManager.importSqlDump();
|
|
116436
|
+
const isInstalledAfterImport = await this.dockerEnvManager.isWordPressInstalled();
|
|
116437
|
+
if (!isInstalledAfterImport) {
|
|
116438
|
+
await this.dockerEnvManager.installWordPress();
|
|
116439
|
+
}
|
|
116440
|
+
}
|
|
116441
|
+
await this.dockerEnvManager.installPlugins();
|
|
116442
|
+
}
|
|
116443
|
+
const dbConfig = this.dockerEnvManager.getDatabaseConfig();
|
|
116444
|
+
this.configManager.setDatabaseConnection(dbConfig);
|
|
116445
|
+
logger.success(`WordPress running at ${wordpressUrl}`);
|
|
116446
|
+
logger.info(` Admin: ${wordpressUrl}/wp-admin (admin / password)`);
|
|
116447
|
+
if (config.dev.databasePort) {
|
|
116448
|
+
logger.info(` Database: 127.0.0.1:${config.dev.databasePort} (wordpress / wordpress)`);
|
|
116449
|
+
}
|
|
116450
|
+
} catch (error) {
|
|
116451
|
+
const errorMessage = error.message;
|
|
116452
|
+
console.error(`
|
|
116453
|
+
❌ ${errorMessage}
|
|
116454
|
+
`);
|
|
116455
|
+
process.exit(1);
|
|
116159
116456
|
}
|
|
116160
|
-
|
|
116161
|
-
|
|
116457
|
+
}
|
|
116458
|
+
async initializeConfig() {
|
|
116459
|
+
const config = this.configManager.getConfig();
|
|
116460
|
+
this.blocksDir = this.configManager.resolvePath(config.paths.blocks);
|
|
116461
|
+
this.outputDir = this.configManager.resolvePath(config.paths.dist);
|
|
116462
|
+
this.webpackConfig = path17.join(__dirname2, "..", "webpack.config.cjs");
|
|
116463
|
+
this.scriptsPath = this.configManager.resolvePath(config.paths.scripts);
|
|
116464
|
+
this.contentDir = this.configManager.resolvePath(config.paths.content);
|
|
116465
|
+
this.templatesDir = this.configManager.resolvePath(config.paths.templates);
|
|
116466
|
+
this.templatesOutputDir = this.configManager.resolvePath(config.paths.templatesOutput);
|
|
116467
|
+
this.templatePartsDir = this.configManager.resolvePath(config.paths.templateParts);
|
|
116468
|
+
this.templatePartsOutputDir = this.configManager.resolvePath(config.paths.partsOutput);
|
|
116469
|
+
if (!fs15.existsSync(this.outputDir)) {
|
|
116470
|
+
fs15.mkdirSync(this.outputDir, { recursive: true });
|
|
116162
116471
|
}
|
|
116163
116472
|
}
|
|
116164
116473
|
initializeManagers() {
|
|
@@ -116179,8 +116488,18 @@ class DevModeOrchestrator {
|
|
|
116179
116488
|
}
|
|
116180
116489
|
async connectWordPress() {
|
|
116181
116490
|
try {
|
|
116182
|
-
const
|
|
116183
|
-
|
|
116491
|
+
const config = this.configManager.getConfig();
|
|
116492
|
+
const dbConfig = config.database || this.dockerEnvManager?.getDatabaseConfig();
|
|
116493
|
+
if (!dbConfig) {
|
|
116494
|
+
throw new Error("No database connection available. Make sure Docker environment is running.");
|
|
116495
|
+
}
|
|
116496
|
+
const wpConfig = {
|
|
116497
|
+
type: "database",
|
|
116498
|
+
wordpressUrl: this.configManager.getWordPressUrl(),
|
|
116499
|
+
database: dbConfig
|
|
116500
|
+
};
|
|
116501
|
+
logger.info(` Using database: ${dbConfig.host}:${dbConfig.port}`);
|
|
116502
|
+
await this.connectionManager.createConnection(wpConfig);
|
|
116184
116503
|
this.pushCommand = new PushCommand(this.blockRegistry);
|
|
116185
116504
|
logger.success("WordPress connection established");
|
|
116186
116505
|
} catch (error) {
|
|
@@ -116190,7 +116509,7 @@ class DevModeOrchestrator {
|
|
|
116190
116509
|
}
|
|
116191
116510
|
}
|
|
116192
116511
|
async scanBlocks() {
|
|
116193
|
-
if (!
|
|
116512
|
+
if (!fs15.existsSync(this.blocksDir)) {
|
|
116194
116513
|
logger.warn(`Blocks directory not found: ${this.blocksDir}`);
|
|
116195
116514
|
return [];
|
|
116196
116515
|
}
|
|
@@ -116208,9 +116527,9 @@ class DevModeOrchestrator {
|
|
|
116208
116527
|
return blocks;
|
|
116209
116528
|
}
|
|
116210
116529
|
async scanDependencies() {
|
|
116211
|
-
await this.dependencyTracker.scanDependencies(this.templatesDir, this.contentDir);
|
|
116530
|
+
await this.dependencyTracker.scanDependencies(this.templatesDir, this.contentDir, this.templatePartsDir);
|
|
116212
116531
|
const stats = this.dependencyTracker.getStats();
|
|
116213
|
-
this.ui.showDependencyScan(stats.totalTemplates, stats.totalPages, stats.totalBlocks);
|
|
116532
|
+
this.ui.showDependencyScan(stats.totalTemplates + stats.totalTemplateParts, stats.totalPages, stats.totalBlocks);
|
|
116214
116533
|
}
|
|
116215
116534
|
async performInitialBuild(blocks) {
|
|
116216
116535
|
const startTime = Date.now();
|
|
@@ -116228,62 +116547,229 @@ class DevModeOrchestrator {
|
|
|
116228
116547
|
await this.componentRegistry.loadAllBlocks();
|
|
116229
116548
|
await this.blockRegistry.loadBuiltBlocks();
|
|
116230
116549
|
this.ui.showInitialBuildComplete(blocks.length, blocks.length, 0, Date.now() - startTime);
|
|
116550
|
+
} else {
|
|
116551
|
+
console.log(`\uD83D\uDCE6 Blocks to build: ${blocksToRebuild.map((b) => b.name).join(", ")}`);
|
|
116552
|
+
let successCount = 0;
|
|
116553
|
+
let failCount = 0;
|
|
116554
|
+
const blockScripts = new Map;
|
|
116555
|
+
const results = await this.workerPool.buildAll(blocksToRebuild, (completed, total, blockName, success) => {
|
|
116556
|
+
if (success) {
|
|
116557
|
+
console.log(` ✅ ${blockName} [${completed}/${total}]`);
|
|
116558
|
+
successCount++;
|
|
116559
|
+
} else {
|
|
116560
|
+
console.log(` ❌ ${blockName} failed [${completed}/${total}]`);
|
|
116561
|
+
failCount++;
|
|
116562
|
+
}
|
|
116563
|
+
});
|
|
116564
|
+
for (const result2 of results) {
|
|
116565
|
+
if (result2.success) {
|
|
116566
|
+
const block = blocksToRebuild.find((b) => b.name === result2.blockName);
|
|
116567
|
+
if (block) {
|
|
116568
|
+
const hash = this.hashManager.calculateSourceHash(block.filePath);
|
|
116569
|
+
this.hashManager.storeHash(block.name, hash);
|
|
116570
|
+
if (block.scripts && block.scripts.length > 0) {
|
|
116571
|
+
const scriptPaths = block.scripts.map((script) => `scripts/${path17.basename(script).replace(/\.ts$/, ".js")}`);
|
|
116572
|
+
blockScripts.set(block.name, scriptPaths);
|
|
116573
|
+
}
|
|
116574
|
+
}
|
|
116575
|
+
}
|
|
116576
|
+
}
|
|
116577
|
+
if (blockScripts.size > 0) {
|
|
116578
|
+
const phpPath = path17.join(path17.dirname(this.outputDir), "functions-blocks-scripts.php");
|
|
116579
|
+
this.phpGenerator.generateScriptRegistrationPHP(blockScripts, phpPath);
|
|
116580
|
+
}
|
|
116581
|
+
await this.generateTypeDefinitions();
|
|
116582
|
+
await this.componentRegistry.loadAllBlocks();
|
|
116583
|
+
await this.blockRegistry.loadBuiltBlocks();
|
|
116584
|
+
this.ui.showInitialBuildComplete(blocks.length, successCount + cachedCount, failCount, Date.now() - startTime);
|
|
116585
|
+
}
|
|
116586
|
+
if (this.options.buildTemplates && this.templatesDir && this.templatesOutputDir) {
|
|
116587
|
+
await this.performInitialTemplateBuild();
|
|
116588
|
+
}
|
|
116589
|
+
if (this.options.buildTemplates && this.templatePartsDir && this.templatePartsOutputDir) {
|
|
116590
|
+
await this.performInitialTemplatePartsBuild();
|
|
116591
|
+
}
|
|
116592
|
+
if (this.options.autoPush && this.pushCommand) {
|
|
116593
|
+
await this.performInitialContentPush();
|
|
116594
|
+
}
|
|
116595
|
+
}
|
|
116596
|
+
async performInitialContentPush() {
|
|
116597
|
+
if (!fs15.existsSync(this.contentDir))
|
|
116598
|
+
return;
|
|
116599
|
+
const postDir = path17.join(this.contentDir, "post");
|
|
116600
|
+
const pageDir = path17.join(this.contentDir, "page");
|
|
116601
|
+
const contentFiles = [];
|
|
116602
|
+
if (fs15.existsSync(postDir)) {
|
|
116603
|
+
contentFiles.push(...this.findMDXFiles(postDir));
|
|
116604
|
+
}
|
|
116605
|
+
if (fs15.existsSync(pageDir)) {
|
|
116606
|
+
contentFiles.push(...this.findMDXFiles(pageDir));
|
|
116607
|
+
}
|
|
116608
|
+
if (contentFiles.length === 0) {
|
|
116231
116609
|
return;
|
|
116232
116610
|
}
|
|
116233
|
-
console.log(
|
|
116611
|
+
console.log(`
|
|
116612
|
+
\uD83D\uDE80 Pushing ${contentFiles.length} content file(s)...`);
|
|
116234
116613
|
let successCount = 0;
|
|
116235
116614
|
let failCount = 0;
|
|
116236
|
-
const
|
|
116237
|
-
|
|
116238
|
-
|
|
116239
|
-
|
|
116615
|
+
for (const filePath2 of contentFiles) {
|
|
116616
|
+
const fileName = path17.basename(filePath2);
|
|
116617
|
+
this.ignoreFileTemporarily(filePath2);
|
|
116618
|
+
try {
|
|
116619
|
+
await this.pushPages([filePath2]);
|
|
116240
116620
|
successCount++;
|
|
116241
|
-
}
|
|
116242
|
-
console.log(` ❌ ${
|
|
116621
|
+
} catch (error) {
|
|
116622
|
+
console.log(` ❌ ${fileName}: ${error.message}`);
|
|
116623
|
+
failCount++;
|
|
116624
|
+
}
|
|
116625
|
+
}
|
|
116626
|
+
if (failCount === 0) {
|
|
116627
|
+
console.log(`✅ Pushed ${successCount} content file(s)
|
|
116628
|
+
`);
|
|
116629
|
+
} else {
|
|
116630
|
+
console.log(`⚠️ Pushed ${successCount} content file(s), ${failCount} failed
|
|
116631
|
+
`);
|
|
116632
|
+
}
|
|
116633
|
+
}
|
|
116634
|
+
async performInitialTemplateBuild() {
|
|
116635
|
+
if (!this.templatesDir || !this.templatesOutputDir)
|
|
116636
|
+
return;
|
|
116637
|
+
if (!fs15.existsSync(this.templatesDir))
|
|
116638
|
+
return;
|
|
116639
|
+
const templateFiles = this.findMDXFiles(this.templatesDir);
|
|
116640
|
+
if (templateFiles.length === 0) {
|
|
116641
|
+
logger.info("No templates found to build");
|
|
116642
|
+
return;
|
|
116643
|
+
}
|
|
116644
|
+
console.log(`
|
|
116645
|
+
\uD83D\uDCC4 Building ${templateFiles.length} template(s)...`);
|
|
116646
|
+
if (!fs15.existsSync(this.templatesOutputDir)) {
|
|
116647
|
+
fs15.mkdirSync(this.templatesOutputDir, { recursive: true });
|
|
116648
|
+
}
|
|
116649
|
+
const renderer = new OfficialMDXRenderer({
|
|
116650
|
+
blockRegistry: this.blockRegistry
|
|
116651
|
+
});
|
|
116652
|
+
renderer.initialize();
|
|
116653
|
+
let successCount = 0;
|
|
116654
|
+
let failCount = 0;
|
|
116655
|
+
for (const templatePath of templateFiles) {
|
|
116656
|
+
const templateName = path17.basename(templatePath, ".mdx");
|
|
116657
|
+
const relativePath = path17.relative(this.templatesDir, templatePath);
|
|
116658
|
+
try {
|
|
116659
|
+
const mdxContent = fs15.readFileSync(templatePath, "utf8");
|
|
116660
|
+
const cleanContent = this.removeFrontmatter(mdxContent);
|
|
116661
|
+
const html5 = await renderer.renderMDXToHTML(cleanContent);
|
|
116662
|
+
const cleanHTML = renderer.postProcessHTML(html5);
|
|
116663
|
+
const outputPath = path17.join(this.templatesOutputDir, `${templateName}.html`);
|
|
116664
|
+
fs15.writeFileSync(outputPath, cleanHTML, "utf8");
|
|
116665
|
+
console.log(` ✅ ${relativePath}`);
|
|
116666
|
+
successCount++;
|
|
116667
|
+
} catch (error) {
|
|
116668
|
+
console.log(` ❌ ${relativePath}: ${error.message}`);
|
|
116243
116669
|
failCount++;
|
|
116244
116670
|
}
|
|
116671
|
+
}
|
|
116672
|
+
if (failCount === 0) {
|
|
116673
|
+
console.log(`✅ Built ${successCount} template(s)`);
|
|
116674
|
+
} else {
|
|
116675
|
+
console.log(`⚠️ Built ${successCount} template(s), ${failCount} failed`);
|
|
116676
|
+
}
|
|
116677
|
+
}
|
|
116678
|
+
async performInitialTemplatePartsBuild() {
|
|
116679
|
+
if (!this.templatePartsDir || !this.templatePartsOutputDir)
|
|
116680
|
+
return;
|
|
116681
|
+
if (!fs15.existsSync(this.templatePartsDir))
|
|
116682
|
+
return;
|
|
116683
|
+
const partFiles = this.findMDXFiles(this.templatePartsDir);
|
|
116684
|
+
if (partFiles.length === 0) {
|
|
116685
|
+
logger.info("No template-parts found to build");
|
|
116686
|
+
return;
|
|
116687
|
+
}
|
|
116688
|
+
console.log(`
|
|
116689
|
+
\uD83E\uDDE9 Building ${partFiles.length} template-part(s)...`);
|
|
116690
|
+
if (!fs15.existsSync(this.templatePartsOutputDir)) {
|
|
116691
|
+
fs15.mkdirSync(this.templatePartsOutputDir, { recursive: true });
|
|
116692
|
+
}
|
|
116693
|
+
const renderer = new OfficialMDXRenderer({
|
|
116694
|
+
blockRegistry: this.blockRegistry
|
|
116245
116695
|
});
|
|
116246
|
-
|
|
116247
|
-
|
|
116248
|
-
|
|
116249
|
-
|
|
116250
|
-
|
|
116251
|
-
|
|
116252
|
-
|
|
116253
|
-
|
|
116254
|
-
|
|
116255
|
-
|
|
116256
|
-
|
|
116696
|
+
renderer.initialize();
|
|
116697
|
+
let successCount = 0;
|
|
116698
|
+
let failCount = 0;
|
|
116699
|
+
for (const partPath of partFiles) {
|
|
116700
|
+
const partName = path17.basename(partPath, ".mdx");
|
|
116701
|
+
const relativePath = path17.relative(this.templatePartsDir, partPath);
|
|
116702
|
+
try {
|
|
116703
|
+
const mdxContent = fs15.readFileSync(partPath, "utf8");
|
|
116704
|
+
const cleanContent = this.removeFrontmatter(mdxContent);
|
|
116705
|
+
const html5 = await renderer.renderMDXToHTML(cleanContent);
|
|
116706
|
+
const cleanHTML = renderer.postProcessHTML(html5);
|
|
116707
|
+
const outputPath = path17.join(this.templatePartsOutputDir, `${partName}.html`);
|
|
116708
|
+
fs15.writeFileSync(outputPath, cleanHTML, "utf8");
|
|
116709
|
+
console.log(` ✅ ${relativePath}`);
|
|
116710
|
+
successCount++;
|
|
116711
|
+
} catch (error) {
|
|
116712
|
+
console.log(` ❌ ${relativePath}: ${error.message}`);
|
|
116713
|
+
failCount++;
|
|
116257
116714
|
}
|
|
116258
116715
|
}
|
|
116259
|
-
if (
|
|
116260
|
-
|
|
116261
|
-
|
|
116716
|
+
if (failCount === 0) {
|
|
116717
|
+
console.log(`✅ Built ${successCount} template-part(s)`);
|
|
116718
|
+
} else {
|
|
116719
|
+
console.log(`⚠️ Built ${successCount} template-part(s), ${failCount} failed`);
|
|
116262
116720
|
}
|
|
116263
|
-
|
|
116264
|
-
|
|
116265
|
-
|
|
116266
|
-
|
|
116721
|
+
}
|
|
116722
|
+
findMDXFiles(dir) {
|
|
116723
|
+
const files = [];
|
|
116724
|
+
const entries = fs15.readdirSync(dir, { withFileTypes: true });
|
|
116725
|
+
for (const entry of entries) {
|
|
116726
|
+
const fullPath = path17.join(dir, entry.name);
|
|
116727
|
+
if (entry.isDirectory()) {
|
|
116728
|
+
files.push(...this.findMDXFiles(fullPath));
|
|
116729
|
+
} else if (entry.isFile() && entry.name.endsWith(".mdx")) {
|
|
116730
|
+
files.push(fullPath);
|
|
116731
|
+
}
|
|
116732
|
+
}
|
|
116733
|
+
return files;
|
|
116267
116734
|
}
|
|
116268
116735
|
startWatchers() {
|
|
116269
116736
|
this.startBlockWatcher();
|
|
116270
116737
|
if (this.templatesDir && this.options.buildTemplates) {
|
|
116271
116738
|
this.startTemplateWatcher();
|
|
116272
116739
|
}
|
|
116740
|
+
if (this.templatePartsDir && this.options.buildTemplates) {
|
|
116741
|
+
this.startTemplatePartWatcher();
|
|
116742
|
+
}
|
|
116273
116743
|
if (this.options.autoPush) {
|
|
116274
116744
|
this.startPageWatcher();
|
|
116275
116745
|
}
|
|
116276
116746
|
}
|
|
116277
|
-
|
|
116278
|
-
|
|
116279
|
-
|
|
116280
|
-
cwd: this.blocksDir,
|
|
116747
|
+
getWatcherOptions() {
|
|
116748
|
+
const isLinux = process.platform === "linux";
|
|
116749
|
+
return {
|
|
116281
116750
|
persistent: true,
|
|
116282
116751
|
ignoreInitial: true,
|
|
116752
|
+
ignored: [
|
|
116753
|
+
"**/node_modules/**",
|
|
116754
|
+
"**/.git/**",
|
|
116755
|
+
"**/dist/**",
|
|
116756
|
+
"**/build/**",
|
|
116757
|
+
"**/*.map"
|
|
116758
|
+
],
|
|
116759
|
+
usePolling: isLinux,
|
|
116760
|
+
interval: isLinux ? 300 : undefined,
|
|
116761
|
+
binaryInterval: isLinux ? 300 : undefined,
|
|
116283
116762
|
awaitWriteFinish: {
|
|
116284
116763
|
stabilityThreshold: 200,
|
|
116285
|
-
pollInterval:
|
|
116764
|
+
pollInterval: 100
|
|
116286
116765
|
}
|
|
116766
|
+
};
|
|
116767
|
+
}
|
|
116768
|
+
startBlockWatcher() {
|
|
116769
|
+
logger.debug(`Watching blocks: ${this.blocksDir}`);
|
|
116770
|
+
const watcher = $watch("**/*.{tsx,ts,jsx,js}", {
|
|
116771
|
+
cwd: this.blocksDir,
|
|
116772
|
+
...this.getWatcherOptions()
|
|
116287
116773
|
});
|
|
116288
116774
|
this.watchers.push(watcher);
|
|
116289
116775
|
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 +116778,41 @@ class DevModeOrchestrator {
|
|
|
116292
116778
|
});
|
|
116293
116779
|
}
|
|
116294
116780
|
startTemplateWatcher() {
|
|
116295
|
-
if (!this.templatesDir || !
|
|
116781
|
+
if (!this.templatesDir || !fs15.existsSync(this.templatesDir))
|
|
116296
116782
|
return;
|
|
116297
116783
|
logger.debug(`Watching templates: ${this.templatesDir}`);
|
|
116298
116784
|
const watcher = $watch("**/*.mdx", {
|
|
116299
116785
|
cwd: this.templatesDir,
|
|
116300
|
-
|
|
116301
|
-
ignoreInitial: true,
|
|
116302
|
-
awaitWriteFinish: {
|
|
116303
|
-
stabilityThreshold: 200,
|
|
116304
|
-
pollInterval: 50
|
|
116305
|
-
}
|
|
116786
|
+
...this.getWatcherOptions()
|
|
116306
116787
|
});
|
|
116307
116788
|
this.watchers.push(watcher);
|
|
116308
116789
|
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
116790
|
}
|
|
116791
|
+
startTemplatePartWatcher() {
|
|
116792
|
+
if (!this.templatePartsDir || !fs15.existsSync(this.templatePartsDir))
|
|
116793
|
+
return;
|
|
116794
|
+
logger.debug(`Watching template-parts: ${this.templatePartsDir}`);
|
|
116795
|
+
const watcher = $watch("**/*.mdx", {
|
|
116796
|
+
cwd: this.templatePartsDir,
|
|
116797
|
+
...this.getWatcherOptions()
|
|
116798
|
+
});
|
|
116799
|
+
this.watchers.push(watcher);
|
|
116800
|
+
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));
|
|
116801
|
+
}
|
|
116310
116802
|
startPageWatcher() {
|
|
116311
|
-
if (!
|
|
116803
|
+
if (!fs15.existsSync(this.contentDir))
|
|
116312
116804
|
return;
|
|
116313
116805
|
logger.debug(`Watching pages: ${this.contentDir}`);
|
|
116314
116806
|
const watcher = $watch(["post/**/*.mdx", "page/**/*.mdx"], {
|
|
116315
116807
|
cwd: this.contentDir,
|
|
116316
|
-
|
|
116317
|
-
ignoreInitial: true,
|
|
116318
|
-
awaitWriteFinish: {
|
|
116319
|
-
stabilityThreshold: 200,
|
|
116320
|
-
pollInterval: 50
|
|
116321
|
-
}
|
|
116808
|
+
...this.getWatcherOptions()
|
|
116322
116809
|
});
|
|
116323
116810
|
this.watchers.push(watcher);
|
|
116324
116811
|
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
116812
|
}
|
|
116326
116813
|
handleBlockFileEvent(eventType, filePath2) {
|
|
116327
|
-
const fullPath =
|
|
116328
|
-
const fileName =
|
|
116814
|
+
const fullPath = path17.resolve(this.blocksDir, filePath2);
|
|
116815
|
+
const fileName = path17.basename(filePath2, path17.extname(filePath2));
|
|
116329
116816
|
const isMainBlock = this.blockFilePaths.has(fileName);
|
|
116330
116817
|
const parentBlock = this.importToBlock.get(fullPath);
|
|
116331
116818
|
if (isMainBlock) {
|
|
@@ -116337,7 +116824,7 @@ class DevModeOrchestrator {
|
|
|
116337
116824
|
}
|
|
116338
116825
|
}
|
|
116339
116826
|
handleTemplateFileEvent(eventType, filePath2) {
|
|
116340
|
-
const fullPath =
|
|
116827
|
+
const fullPath = path17.resolve(this.templatesDir, filePath2);
|
|
116341
116828
|
this.changeQueue.queueTemplateChange(fullPath, eventType);
|
|
116342
116829
|
if (eventType === "unlink") {
|
|
116343
116830
|
this.dependencyTracker.removeFile(fullPath);
|
|
@@ -116345,8 +116832,17 @@ class DevModeOrchestrator {
|
|
|
116345
116832
|
this.dependencyTracker.updateFileDependencies(fullPath, "template");
|
|
116346
116833
|
}
|
|
116347
116834
|
}
|
|
116835
|
+
handleTemplatePartFileEvent(eventType, filePath2) {
|
|
116836
|
+
const fullPath = path17.resolve(this.templatePartsDir, filePath2);
|
|
116837
|
+
this.changeQueue.queueTemplatePartChange(fullPath, eventType);
|
|
116838
|
+
if (eventType === "unlink") {
|
|
116839
|
+
this.dependencyTracker.removeFile(fullPath);
|
|
116840
|
+
} else {
|
|
116841
|
+
this.dependencyTracker.updateFileDependencies(fullPath, "templatePart");
|
|
116842
|
+
}
|
|
116843
|
+
}
|
|
116348
116844
|
handlePageFileEvent(eventType, filePath2) {
|
|
116349
|
-
const fullPath =
|
|
116845
|
+
const fullPath = path17.resolve(this.contentDir, filePath2);
|
|
116350
116846
|
if (this.ignoredFiles.has(fullPath)) {
|
|
116351
116847
|
logger.debug(`Ignoring self-triggered change: ${filePath2}`);
|
|
116352
116848
|
return;
|
|
@@ -116377,15 +116873,39 @@ class DevModeOrchestrator {
|
|
|
116377
116873
|
await this.buildBlocks(blockNames);
|
|
116378
116874
|
}
|
|
116379
116875
|
const cascade = this.dependencyTracker.getCascade(blockNames);
|
|
116876
|
+
await this.processDependentArtifacts(batch, cascade);
|
|
116877
|
+
}
|
|
116878
|
+
async processDependentArtifacts(batch, cascade) {
|
|
116380
116879
|
const allTemplates = [
|
|
116381
116880
|
...new Set([...batch.templates, ...cascade.templates])
|
|
116382
116881
|
];
|
|
116882
|
+
const allTemplateParts = [
|
|
116883
|
+
...new Set([...batch.templateParts, ...cascade.templateParts])
|
|
116884
|
+
];
|
|
116383
116885
|
const allPages = [...new Set([...batch.pages, ...cascade.pages])];
|
|
116384
116886
|
if (allTemplates.length > 0 && this.options.buildTemplates) {
|
|
116385
|
-
await this.
|
|
116887
|
+
await this.processArtifacts("template", allTemplates);
|
|
116888
|
+
}
|
|
116889
|
+
if (allTemplateParts.length > 0 && this.options.buildTemplates) {
|
|
116890
|
+
await this.processArtifacts("templatePart", allTemplateParts);
|
|
116386
116891
|
}
|
|
116387
116892
|
if (allPages.length > 0 && this.options.autoPush) {
|
|
116388
|
-
await this.
|
|
116893
|
+
await this.processArtifacts("page", allPages);
|
|
116894
|
+
}
|
|
116895
|
+
}
|
|
116896
|
+
async processArtifacts(type, paths) {
|
|
116897
|
+
switch (type) {
|
|
116898
|
+
case "template":
|
|
116899
|
+
await this.buildTemplates(paths);
|
|
116900
|
+
break;
|
|
116901
|
+
case "templatePart":
|
|
116902
|
+
await this.buildTemplateParts(paths);
|
|
116903
|
+
break;
|
|
116904
|
+
case "page":
|
|
116905
|
+
await this.pushPages(paths);
|
|
116906
|
+
break;
|
|
116907
|
+
default:
|
|
116908
|
+
logger.warn(`Unknown artifact type: ${type}`);
|
|
116389
116909
|
}
|
|
116390
116910
|
}
|
|
116391
116911
|
async buildBlocks(blockNames) {
|
|
@@ -116443,18 +116963,63 @@ class DevModeOrchestrator {
|
|
|
116443
116963
|
});
|
|
116444
116964
|
renderer.initialize();
|
|
116445
116965
|
for (const templatePath of templatePaths) {
|
|
116446
|
-
const templateName =
|
|
116966
|
+
const templateName = path17.basename(templatePath, ".mdx");
|
|
116967
|
+
const relativePath = this.templatesDir ? path17.relative(this.templatesDir, templatePath) : templateName;
|
|
116447
116968
|
const taskId = this.taskScheduler.scheduleTemplateBuild(templatePath, []);
|
|
116969
|
+
const startTime = Date.now();
|
|
116970
|
+
try {
|
|
116971
|
+
const mdxContent = fs15.readFileSync(templatePath, "utf8");
|
|
116972
|
+
const cleanContent = this.removeFrontmatter(mdxContent);
|
|
116973
|
+
const html5 = await renderer.renderMDXToHTML(cleanContent);
|
|
116974
|
+
const cleanHTML = renderer.postProcessHTML(html5);
|
|
116975
|
+
const outputPath = path17.join(this.templatesOutputDir, `${templateName}.html`);
|
|
116976
|
+
fs15.writeFileSync(outputPath, cleanHTML, "utf8");
|
|
116977
|
+
const duration = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
116978
|
+
console.log(`\uD83D\uDCC4 ${relativePath} → ✅ (${duration}s)`);
|
|
116979
|
+
this.taskScheduler.completeTask(taskId, true);
|
|
116980
|
+
} catch (error) {
|
|
116981
|
+
const errorMsg = error.message;
|
|
116982
|
+
if (errorMsg.length > 60) {
|
|
116983
|
+
console.log(`\uD83D\uDCC4 ${relativePath} → ❌`);
|
|
116984
|
+
console.log(` ${errorMsg}`);
|
|
116985
|
+
} else {
|
|
116986
|
+
console.log(`\uD83D\uDCC4 ${relativePath} → ❌ ${errorMsg}`);
|
|
116987
|
+
}
|
|
116988
|
+
this.taskScheduler.completeTask(taskId, false, null, errorMsg);
|
|
116989
|
+
}
|
|
116990
|
+
}
|
|
116991
|
+
}
|
|
116992
|
+
async buildTemplateParts(partPaths) {
|
|
116993
|
+
if (!this.templatePartsOutputDir)
|
|
116994
|
+
return;
|
|
116995
|
+
const renderer = new OfficialMDXRenderer({
|
|
116996
|
+
blockRegistry: this.blockRegistry
|
|
116997
|
+
});
|
|
116998
|
+
renderer.initialize();
|
|
116999
|
+
for (const partPath of partPaths) {
|
|
117000
|
+
const partName = path17.basename(partPath, ".mdx");
|
|
117001
|
+
const relativePath = this.templatePartsDir ? path17.relative(this.templatePartsDir, partPath) : partName;
|
|
117002
|
+
const taskId = this.taskScheduler.scheduleTemplateBuild(partPath, []);
|
|
117003
|
+
const startTime = Date.now();
|
|
116448
117004
|
try {
|
|
116449
|
-
const mdxContent =
|
|
117005
|
+
const mdxContent = fs15.readFileSync(partPath, "utf8");
|
|
116450
117006
|
const cleanContent = this.removeFrontmatter(mdxContent);
|
|
116451
117007
|
const html5 = await renderer.renderMDXToHTML(cleanContent);
|
|
116452
117008
|
const cleanHTML = renderer.postProcessHTML(html5);
|
|
116453
|
-
const outputPath =
|
|
116454
|
-
|
|
117009
|
+
const outputPath = path17.join(this.templatePartsOutputDir, `${partName}.html`);
|
|
117010
|
+
fs15.writeFileSync(outputPath, cleanHTML, "utf8");
|
|
117011
|
+
const duration = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
117012
|
+
console.log(`\uD83E\uDDE9 ${relativePath} → ✅ (${duration}s)`);
|
|
116455
117013
|
this.taskScheduler.completeTask(taskId, true);
|
|
116456
117014
|
} catch (error) {
|
|
116457
|
-
|
|
117015
|
+
const errorMsg = error.message;
|
|
117016
|
+
if (errorMsg.length > 60) {
|
|
117017
|
+
console.log(`\uD83E\uDDE9 ${relativePath} → ❌`);
|
|
117018
|
+
console.log(` ${errorMsg}`);
|
|
117019
|
+
} else {
|
|
117020
|
+
console.log(`\uD83E\uDDE9 ${relativePath} → ❌ ${errorMsg}`);
|
|
117021
|
+
}
|
|
117022
|
+
this.taskScheduler.completeTask(taskId, false, null, errorMsg);
|
|
116458
117023
|
}
|
|
116459
117024
|
}
|
|
116460
117025
|
}
|
|
@@ -116463,7 +117028,7 @@ class DevModeOrchestrator {
|
|
|
116463
117028
|
return;
|
|
116464
117029
|
for (const pagePath of pagePaths) {
|
|
116465
117030
|
const taskId = this.taskScheduler.schedulePagePush(pagePath, []);
|
|
116466
|
-
const fileName =
|
|
117031
|
+
const fileName = path17.basename(pagePath);
|
|
116467
117032
|
const startTime = Date.now();
|
|
116468
117033
|
this.ignoreFileTemporarily(pagePath);
|
|
116469
117034
|
try {
|
|
@@ -116491,7 +117056,7 @@ class DevModeOrchestrator {
|
|
|
116491
117056
|
try {
|
|
116492
117057
|
const blocks = await this.typeGenerator.extractBlocksFromDist(this.outputDir);
|
|
116493
117058
|
if (blocks.length > 0) {
|
|
116494
|
-
const typesPath =
|
|
117059
|
+
const typesPath = path17.join(this.outputDir, "blocks.d.ts");
|
|
116495
117060
|
await this.typeGenerator.generateDefinitions(blocks, typesPath);
|
|
116496
117061
|
}
|
|
116497
117062
|
} catch (error) {
|
|
@@ -116516,6 +117081,11 @@ class DevModeOrchestrator {
|
|
|
116516
117081
|
try {
|
|
116517
117082
|
await this.connectionManager.closeConnection();
|
|
116518
117083
|
} catch {}
|
|
117084
|
+
if (this.dockerEnvManager) {
|
|
117085
|
+
try {
|
|
117086
|
+
await this.dockerEnvManager.stop();
|
|
117087
|
+
} catch {}
|
|
117088
|
+
}
|
|
116519
117089
|
this.ui.showShutdownComplete();
|
|
116520
117090
|
process.exit(0);
|
|
116521
117091
|
};
|
|
@@ -116541,7 +117111,8 @@ class DevCommand {
|
|
|
116541
117111
|
concurrency: options.concurrency,
|
|
116542
117112
|
autoPush: options.push !== false,
|
|
116543
117113
|
buildTemplates: options.templates !== false,
|
|
116544
|
-
verbose: options.verbose ?? false
|
|
117114
|
+
verbose: options.verbose ?? false,
|
|
117115
|
+
skipEnv: options.skipEnv ?? false
|
|
116545
117116
|
};
|
|
116546
117117
|
this.orchestrator = new DevModeOrchestrator(devOptions);
|
|
116547
117118
|
try {
|
|
@@ -116559,37 +117130,37 @@ class DevCommand {
|
|
|
116559
117130
|
}
|
|
116560
117131
|
|
|
116561
117132
|
// src/commands/build-command.ts
|
|
116562
|
-
import * as
|
|
117133
|
+
import * as path22 from "path";
|
|
116563
117134
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
116564
117135
|
|
|
116565
117136
|
// src/build/block-builder.ts
|
|
116566
|
-
import * as
|
|
116567
|
-
import * as
|
|
117137
|
+
import * as fs18 from "fs";
|
|
117138
|
+
import * as path20 from "path";
|
|
116568
117139
|
|
|
116569
117140
|
// src/build/webpack-runner.ts
|
|
116570
|
-
import * as
|
|
116571
|
-
import * as
|
|
116572
|
-
import { execSync } from "child_process";
|
|
117141
|
+
import * as path18 from "path";
|
|
117142
|
+
import * as fs16 from "fs";
|
|
117143
|
+
import { execSync as execSync2 } from "child_process";
|
|
116573
117144
|
var import_chalk3 = __toESM(require_source(), 1);
|
|
116574
117145
|
|
|
116575
117146
|
class WebpackRunner {
|
|
116576
117147
|
async runBuild(entryPoint, outputDir, webpackConfigPath) {
|
|
116577
117148
|
logger.debug(`Running webpack build for: ${entryPoint}`);
|
|
116578
|
-
if (!
|
|
117149
|
+
if (!fs16.existsSync(webpackConfigPath)) {
|
|
116579
117150
|
const error = `Webpack config not found: ${webpackConfigPath}`;
|
|
116580
117151
|
console.error(import_chalk3.default.red(`
|
|
116581
117152
|
❌ ${error}
|
|
116582
117153
|
`));
|
|
116583
117154
|
throw new Error(error);
|
|
116584
117155
|
}
|
|
116585
|
-
if (!
|
|
117156
|
+
if (!fs16.existsSync(entryPoint)) {
|
|
116586
117157
|
const error = `Entry point not found: ${entryPoint}`;
|
|
116587
117158
|
console.error(import_chalk3.default.red(`
|
|
116588
117159
|
❌ ${error}
|
|
116589
117160
|
`));
|
|
116590
117161
|
throw new Error(error);
|
|
116591
117162
|
}
|
|
116592
|
-
|
|
117163
|
+
fs16.mkdirSync(outputDir, { recursive: true });
|
|
116593
117164
|
const webpackBinary = this.findWebpackBinary();
|
|
116594
117165
|
logger.debug(`Using webpack binary: ${webpackBinary}`);
|
|
116595
117166
|
const envVars = {
|
|
@@ -116600,9 +117171,9 @@ class WebpackRunner {
|
|
|
116600
117171
|
const command = `${webpackBinary} --config "${webpackConfigPath}" ${envString} --mode production`;
|
|
116601
117172
|
logger.debug(`Full command: ${command}`);
|
|
116602
117173
|
try {
|
|
116603
|
-
const workingDir =
|
|
117174
|
+
const workingDir = path18.dirname(webpackConfigPath);
|
|
116604
117175
|
logger.debug(`Running webpack from directory: ${workingDir}`);
|
|
116605
|
-
const output2 =
|
|
117176
|
+
const output2 = execSync2(command, {
|
|
116606
117177
|
cwd: workingDir,
|
|
116607
117178
|
encoding: "utf8",
|
|
116608
117179
|
stdio: "pipe"
|
|
@@ -116619,7 +117190,7 @@ class WebpackRunner {
|
|
|
116619
117190
|
console.error(import_chalk3.default.gray(command));
|
|
116620
117191
|
console.error("");
|
|
116621
117192
|
console.error(import_chalk3.default.yellow("Working directory:"));
|
|
116622
|
-
console.error(import_chalk3.default.gray(
|
|
117193
|
+
console.error(import_chalk3.default.gray(path18.dirname(webpackConfigPath)));
|
|
116623
117194
|
console.error("");
|
|
116624
117195
|
if (error.stdout && error.stdout.trim()) {
|
|
116625
117196
|
console.error(import_chalk3.default.yellow("Standard output:"));
|
|
@@ -116643,13 +117214,13 @@ class WebpackRunner {
|
|
|
116643
117214
|
}
|
|
116644
117215
|
findWebpackBinary() {
|
|
116645
117216
|
const possiblePaths = [
|
|
116646
|
-
|
|
116647
|
-
|
|
116648
|
-
|
|
116649
|
-
|
|
117217
|
+
path18.join(process.cwd(), "packages", "block", "node_modules", ".bin", "webpack"),
|
|
117218
|
+
path18.join(process.cwd(), "node_modules", ".bin", "webpack"),
|
|
117219
|
+
path18.join(import.meta.dirname, "..", "..", "..", "node_modules", ".bin", "webpack"),
|
|
117220
|
+
path18.join(process.cwd(), "..", "node_modules", ".bin", "webpack")
|
|
116650
117221
|
];
|
|
116651
117222
|
for (const webpackPath of possiblePaths) {
|
|
116652
|
-
if (
|
|
117223
|
+
if (fs16.existsSync(webpackPath)) {
|
|
116653
117224
|
logger.debug(`Found webpack at: ${webpackPath}`);
|
|
116654
117225
|
return webpackPath;
|
|
116655
117226
|
}
|
|
@@ -116660,15 +117231,15 @@ class WebpackRunner {
|
|
|
116660
117231
|
}
|
|
116661
117232
|
|
|
116662
117233
|
// src/build/script-builder.ts
|
|
116663
|
-
import * as
|
|
116664
|
-
import * as
|
|
117234
|
+
import * as fs17 from "fs";
|
|
117235
|
+
import * as path19 from "path";
|
|
116665
117236
|
import * as esbuild from "esbuild";
|
|
116666
117237
|
class ScriptBuilder {
|
|
116667
117238
|
async buildScript(scriptPath, outputDir, scriptName) {
|
|
116668
117239
|
try {
|
|
116669
117240
|
logger.debug(`Building script: ${scriptName}`);
|
|
116670
|
-
|
|
116671
|
-
const outputPath =
|
|
117241
|
+
fs17.mkdirSync(outputDir, { recursive: true });
|
|
117242
|
+
const outputPath = path19.join(outputDir, scriptName.replace(/\.ts$/, ".js"));
|
|
116672
117243
|
await esbuild.build({
|
|
116673
117244
|
entryPoints: [scriptPath],
|
|
116674
117245
|
outfile: outputPath,
|
|
@@ -116698,19 +117269,19 @@ class ScriptBuilder {
|
|
|
116698
117269
|
async buildScripts(scripts, scriptsPath, outputDir) {
|
|
116699
117270
|
const outputPaths = [];
|
|
116700
117271
|
for (const script of scripts) {
|
|
116701
|
-
const scriptPath =
|
|
116702
|
-
if (!
|
|
117272
|
+
const scriptPath = path19.resolve(scriptsPath, script);
|
|
117273
|
+
if (!fs17.existsSync(scriptPath)) {
|
|
116703
117274
|
logger.warn(`Script not found: ${scriptPath}`);
|
|
116704
117275
|
continue;
|
|
116705
117276
|
}
|
|
116706
|
-
const scriptName =
|
|
117277
|
+
const scriptName = path19.basename(script);
|
|
116707
117278
|
const outputPath = await this.buildScript(scriptPath, outputDir, scriptName);
|
|
116708
117279
|
outputPaths.push(outputPath);
|
|
116709
117280
|
}
|
|
116710
117281
|
return outputPaths;
|
|
116711
117282
|
}
|
|
116712
117283
|
getRelativeScriptPath(blockDistPath, scriptPath) {
|
|
116713
|
-
const relativePath =
|
|
117284
|
+
const relativePath = path19.relative(blockDistPath, scriptPath);
|
|
116714
117285
|
return relativePath.replace(/\\/g, "/");
|
|
116715
117286
|
}
|
|
116716
117287
|
}
|
|
@@ -116724,17 +117295,17 @@ class BlockBuilder {
|
|
|
116724
117295
|
constructor() {
|
|
116725
117296
|
this.webpackRunner = new WebpackRunner;
|
|
116726
117297
|
this.scriptBuilder = new ScriptBuilder;
|
|
116727
|
-
this.tempDir =
|
|
117298
|
+
this.tempDir = path20.join(process.cwd(), ".wordpress-flow-temp");
|
|
116728
117299
|
}
|
|
116729
117300
|
async buildBlock(block, outputDir, webpackConfigPath, scriptsPath) {
|
|
116730
117301
|
logger.debug(`Building block: ${block.name}`);
|
|
116731
|
-
|
|
117302
|
+
fs18.mkdirSync(this.tempDir, { recursive: true });
|
|
116732
117303
|
try {
|
|
116733
117304
|
logger.debug(`[1/6] Generating entry point...`);
|
|
116734
117305
|
const entryPoint = await this.generateEntryPoint(block);
|
|
116735
117306
|
logger.debug(`[2/6] Creating output directory...`);
|
|
116736
|
-
const blockOutputDir =
|
|
116737
|
-
|
|
117307
|
+
const blockOutputDir = path20.join(outputDir, block.name);
|
|
117308
|
+
fs18.mkdirSync(blockOutputDir, { recursive: true });
|
|
116738
117309
|
let scriptPaths = [];
|
|
116739
117310
|
if (block.scripts && block.scripts.length > 0 && scriptsPath) {
|
|
116740
117311
|
logger.debug(`[3/6] Building ${block.scripts.length} script(s)...`);
|
|
@@ -116761,7 +117332,7 @@ class BlockBuilder {
|
|
|
116761
117332
|
}
|
|
116762
117333
|
}
|
|
116763
117334
|
async buildBlockScripts(scripts, scriptsPath, outputDir) {
|
|
116764
|
-
const scriptsOutputDir =
|
|
117335
|
+
const scriptsOutputDir = path20.join(path20.dirname(outputDir), "scripts");
|
|
116765
117336
|
return await this.scriptBuilder.buildScripts(scripts, scriptsPath, scriptsOutputDir);
|
|
116766
117337
|
}
|
|
116767
117338
|
async generateEntryPoint(block) {
|
|
@@ -116785,14 +117356,14 @@ if (document.readyState === 'loading') {
|
|
|
116785
117356
|
blockInstance.register();
|
|
116786
117357
|
}
|
|
116787
117358
|
`;
|
|
116788
|
-
const entryPath =
|
|
116789
|
-
|
|
117359
|
+
const entryPath = path20.join(this.tempDir, `${block.name}-entry.js`);
|
|
117360
|
+
fs18.writeFileSync(entryPath, entryContent, "utf8");
|
|
116790
117361
|
return entryPath;
|
|
116791
117362
|
}
|
|
116792
117363
|
async generateSSRVersion(block, outputDir) {
|
|
116793
117364
|
try {
|
|
116794
117365
|
logger.debug(`Generating SSR version for ${block.name} using esbuild`);
|
|
116795
|
-
const ssrPath =
|
|
117366
|
+
const ssrPath = path20.join(outputDir, "ssr.js");
|
|
116796
117367
|
await esbuild2.build({
|
|
116797
117368
|
entryPoints: [block.filePath],
|
|
116798
117369
|
outfile: ssrPath,
|
|
@@ -116832,8 +117403,8 @@ if (document.readyState === 'loading') {
|
|
|
116832
117403
|
throw new Error(`Block ${block.name} must export a valid block instance with toBlockJson() method`);
|
|
116833
117404
|
}
|
|
116834
117405
|
const blockJson = blockInstance.toBlockJson();
|
|
116835
|
-
const blockJsonPath =
|
|
116836
|
-
|
|
117406
|
+
const blockJsonPath = path20.join(outputDir, "block.json");
|
|
117407
|
+
fs18.writeFileSync(blockJsonPath, JSON.stringify(blockJson, null, 2), "utf8");
|
|
116837
117408
|
logger.debug(`Generated block.json for ${block.name}`);
|
|
116838
117409
|
} catch (error) {
|
|
116839
117410
|
logger.error(`Failed to generate block.json for ${block.name}:`, error);
|
|
@@ -116856,8 +117427,8 @@ if (document.readyState === 'loading') {
|
|
|
116856
117427
|
editorStyle: "file:./index.css",
|
|
116857
117428
|
style: "file:./style-index.css"
|
|
116858
117429
|
};
|
|
116859
|
-
const blockJsonPath =
|
|
116860
|
-
|
|
117430
|
+
const blockJsonPath = path20.join(outputDir, "block.json");
|
|
117431
|
+
fs18.writeFileSync(blockJsonPath, JSON.stringify(fallbackBlockJson, null, 2), "utf8");
|
|
116861
117432
|
logger.warn(`Used fallback block.json for ${block.name}`);
|
|
116862
117433
|
}
|
|
116863
117434
|
}
|
|
@@ -116869,7 +117440,7 @@ if (document.readyState === 'loading') {
|
|
|
116869
117440
|
}
|
|
116870
117441
|
async compileAndImport(filePath2) {
|
|
116871
117442
|
try {
|
|
116872
|
-
const tempFile =
|
|
117443
|
+
const tempFile = path20.join(this.tempDir, `${path20.basename(filePath2, path20.extname(filePath2))}-compiled.js`);
|
|
116873
117444
|
logger.debug(`Compiling ${filePath2} to ${tempFile}`);
|
|
116874
117445
|
if (typeof global.React === "undefined") {
|
|
116875
117446
|
global.React = require_react();
|
|
@@ -116898,8 +117469,8 @@ if (document.readyState === 'loading') {
|
|
|
116898
117469
|
}
|
|
116899
117470
|
}
|
|
116900
117471
|
parseBlockFromSource(filePath2) {
|
|
116901
|
-
const content4 =
|
|
116902
|
-
const blockName =
|
|
117472
|
+
const content4 = fs18.readFileSync(filePath2, "utf8");
|
|
117473
|
+
const blockName = path20.basename(filePath2, ".tsx");
|
|
116903
117474
|
const blockData = this.extractBlockDataFromSource(content4, filePath2);
|
|
116904
117475
|
return {
|
|
116905
117476
|
toBlockJson: () => {
|
|
@@ -117009,22 +117580,22 @@ if (document.readyState === 'loading') {
|
|
|
117009
117580
|
const requiredFiles = ["block.json", "index.js", "ssr.js"];
|
|
117010
117581
|
const optionalFiles = ["index.asset.php", "index.css", "style-index.css"];
|
|
117011
117582
|
for (const file of requiredFiles) {
|
|
117012
|
-
const filePath2 =
|
|
117013
|
-
if (!
|
|
117583
|
+
const filePath2 = path20.join(outputDir, file);
|
|
117584
|
+
if (!fs18.existsSync(filePath2)) {
|
|
117014
117585
|
throw new Error(`Required build output file missing: ${file}`);
|
|
117015
117586
|
}
|
|
117016
117587
|
}
|
|
117017
117588
|
for (const file of optionalFiles) {
|
|
117018
|
-
const filePath2 =
|
|
117019
|
-
if (
|
|
117589
|
+
const filePath2 = path20.join(outputDir, file);
|
|
117590
|
+
if (fs18.existsSync(filePath2)) {
|
|
117020
117591
|
logger.debug(`Generated optional file: ${file}`);
|
|
117021
117592
|
}
|
|
117022
117593
|
}
|
|
117023
117594
|
}
|
|
117024
117595
|
cleanupTempFiles() {
|
|
117025
117596
|
try {
|
|
117026
|
-
if (
|
|
117027
|
-
|
|
117597
|
+
if (fs18.existsSync(this.tempDir)) {
|
|
117598
|
+
fs18.rmSync(this.tempDir, { recursive: true, force: true });
|
|
117028
117599
|
}
|
|
117029
117600
|
} catch (error) {
|
|
117030
117601
|
logger.warn("Failed to clean up temp files:", error);
|
|
@@ -117034,7 +117605,7 @@ if (document.readyState === 'loading') {
|
|
|
117034
117605
|
|
|
117035
117606
|
// src/build/worker-pool.ts
|
|
117036
117607
|
import { Worker as Worker2 } from "worker_threads";
|
|
117037
|
-
import * as
|
|
117608
|
+
import * as path21 from "path";
|
|
117038
117609
|
import * as os2 from "os";
|
|
117039
117610
|
class WorkerPool {
|
|
117040
117611
|
concurrency;
|
|
@@ -117047,7 +117618,7 @@ class WorkerPool {
|
|
|
117047
117618
|
this.outputDir = options.outputDir;
|
|
117048
117619
|
this.webpackConfigPath = options.webpackConfigPath;
|
|
117049
117620
|
this.scriptsPath = options.scriptsPath;
|
|
117050
|
-
this.workerPath =
|
|
117621
|
+
this.workerPath = path21.join(import.meta.dirname, "build", "block-build-worker.js");
|
|
117051
117622
|
}
|
|
117052
117623
|
async buildAll(blocks, onProgress) {
|
|
117053
117624
|
const results = [];
|
|
@@ -117056,7 +117627,7 @@ class WorkerPool {
|
|
|
117056
117627
|
const total = blocks.length;
|
|
117057
117628
|
let activeWorkers = 0;
|
|
117058
117629
|
logger.info(`Building ${total} block(s) with ${this.concurrency} worker(s)`);
|
|
117059
|
-
return new Promise((
|
|
117630
|
+
return new Promise((resolve8, reject) => {
|
|
117060
117631
|
const processNext = () => {
|
|
117061
117632
|
while (activeWorkers < this.concurrency && queue.length > 0) {
|
|
117062
117633
|
const block = queue.shift();
|
|
@@ -117069,7 +117640,7 @@ class WorkerPool {
|
|
|
117069
117640
|
if (queue.length > 0) {
|
|
117070
117641
|
processNext();
|
|
117071
117642
|
} else if (activeWorkers === 0) {
|
|
117072
|
-
|
|
117643
|
+
resolve8(results);
|
|
117073
117644
|
}
|
|
117074
117645
|
}).catch((error) => {
|
|
117075
117646
|
const result2 = {
|
|
@@ -117084,7 +117655,7 @@ class WorkerPool {
|
|
|
117084
117655
|
if (queue.length > 0) {
|
|
117085
117656
|
processNext();
|
|
117086
117657
|
} else if (activeWorkers === 0) {
|
|
117087
|
-
|
|
117658
|
+
resolve8(results);
|
|
117088
117659
|
}
|
|
117089
117660
|
});
|
|
117090
117661
|
}
|
|
@@ -117093,8 +117664,8 @@ class WorkerPool {
|
|
|
117093
117664
|
});
|
|
117094
117665
|
}
|
|
117095
117666
|
buildBlockInWorker(block) {
|
|
117096
|
-
return new Promise((
|
|
117097
|
-
const tempDir =
|
|
117667
|
+
return new Promise((resolve8, reject) => {
|
|
117668
|
+
const tempDir = path21.join(process.cwd(), ".wordpress-flow-temp", `worker-${block.name}-${Date.now()}`);
|
|
117098
117669
|
const workerData = {
|
|
117099
117670
|
block: {
|
|
117100
117671
|
name: block.name,
|
|
@@ -117114,7 +117685,7 @@ class WorkerPool {
|
|
|
117114
117685
|
worker.on("message", (result2) => {
|
|
117115
117686
|
clearTimeout(timeout);
|
|
117116
117687
|
worker.terminate();
|
|
117117
|
-
|
|
117688
|
+
resolve8(result2);
|
|
117118
117689
|
});
|
|
117119
117690
|
worker.on("error", (error) => {
|
|
117120
117691
|
clearTimeout(timeout);
|
|
@@ -117133,7 +117704,7 @@ class WorkerPool {
|
|
|
117133
117704
|
|
|
117134
117705
|
// src/commands/build-command.ts
|
|
117135
117706
|
var __filename3 = fileURLToPath5(import.meta.url);
|
|
117136
|
-
var __dirname3 =
|
|
117707
|
+
var __dirname3 = path22.dirname(__filename3);
|
|
117137
117708
|
|
|
117138
117709
|
class BuildCommand {
|
|
117139
117710
|
configManager;
|
|
@@ -117153,18 +117724,16 @@ class BuildCommand {
|
|
|
117153
117724
|
async execute(options) {
|
|
117154
117725
|
logger.progress("Starting build operation...");
|
|
117155
117726
|
try {
|
|
117156
|
-
const
|
|
117157
|
-
const blocksDir = this.configManager.resolvePath(options.blocksDir ||
|
|
117158
|
-
const outputDir = this.configManager.resolvePath(options.outputDir ||
|
|
117727
|
+
const config = this.configManager.getConfig();
|
|
117728
|
+
const blocksDir = this.configManager.resolvePath(options.blocksDir || config.paths.blocks);
|
|
117729
|
+
const outputDir = this.configManager.resolvePath(options.outputDir || config.paths.dist);
|
|
117159
117730
|
let webpackConfig;
|
|
117160
117731
|
if (options.webpackConfig) {
|
|
117161
117732
|
webpackConfig = this.configManager.resolvePath(options.webpackConfig);
|
|
117162
|
-
} else if (config2.build?.webpackConfig) {
|
|
117163
|
-
webpackConfig = this.configManager.resolvePath(config2.build.webpackConfig);
|
|
117164
117733
|
} else {
|
|
117165
|
-
webpackConfig =
|
|
117734
|
+
webpackConfig = path22.join(__dirname3, "..", "webpack.config.cjs");
|
|
117166
117735
|
}
|
|
117167
|
-
const scriptsPath =
|
|
117736
|
+
const scriptsPath = this.configManager.resolvePath(config.paths.scripts);
|
|
117168
117737
|
logger.info(`Scanning blocks in: ${blocksDir}`);
|
|
117169
117738
|
logger.info(`Output directory: ${outputDir}`);
|
|
117170
117739
|
if (scriptsPath) {
|
|
@@ -117211,7 +117780,7 @@ class BuildCommand {
|
|
|
117211
117780
|
if (block.scripts && block.scripts.length > 0) {
|
|
117212
117781
|
const result2 = results.find((r) => r.blockName === block.name);
|
|
117213
117782
|
if (result2?.success) {
|
|
117214
|
-
const scriptPaths = block.scripts.map((script) => `scripts/${
|
|
117783
|
+
const scriptPaths = block.scripts.map((script) => `dist/scripts/${path22.basename(script).replace(/\.ts$/, ".js")}`);
|
|
117215
117784
|
this.blockScripts.set(block.name, scriptPaths);
|
|
117216
117785
|
}
|
|
117217
117786
|
}
|
|
@@ -117225,7 +117794,7 @@ Failed to build ${failures.length} block(s):`);
|
|
|
117225
117794
|
}
|
|
117226
117795
|
}
|
|
117227
117796
|
if (this.blockScripts.size > 0) {
|
|
117228
|
-
const phpPath =
|
|
117797
|
+
const phpPath = path22.join(path22.dirname(outputDir), "functions-blocks-scripts.php");
|
|
117229
117798
|
this.phpGenerator.generateScriptRegistrationPHP(this.blockScripts, phpPath);
|
|
117230
117799
|
}
|
|
117231
117800
|
await this.generateTypeDefinitions(outputDir);
|
|
@@ -117253,7 +117822,7 @@ Failed to build ${failures.length} block(s):`);
|
|
|
117253
117822
|
logger.warn("No blocks found for type generation");
|
|
117254
117823
|
return;
|
|
117255
117824
|
}
|
|
117256
|
-
const typesPath =
|
|
117825
|
+
const typesPath = path22.join(outputDir, "blocks.d.ts");
|
|
117257
117826
|
await this.typeGenerator.generateDefinitions(blocks, typesPath);
|
|
117258
117827
|
logger.success(`✅ Generated TypeScript definitions for ${blocks.length} block(s)`);
|
|
117259
117828
|
} catch (error) {
|
|
@@ -117263,8 +117832,8 @@ Failed to build ${failures.length} block(s):`);
|
|
|
117263
117832
|
}
|
|
117264
117833
|
|
|
117265
117834
|
// src/commands/build-templates-command.ts
|
|
117266
|
-
import * as
|
|
117267
|
-
import * as
|
|
117835
|
+
import * as fs19 from "fs";
|
|
117836
|
+
import * as path23 from "path";
|
|
117268
117837
|
class BuildTemplatesCommand {
|
|
117269
117838
|
configManager;
|
|
117270
117839
|
constructor() {
|
|
@@ -117272,28 +117841,18 @@ class BuildTemplatesCommand {
|
|
|
117272
117841
|
}
|
|
117273
117842
|
async execute(options = {}) {
|
|
117274
117843
|
logger.progress("Starting template build operation...");
|
|
117275
|
-
const
|
|
117276
|
-
const
|
|
117277
|
-
|
|
117278
|
-
|
|
117279
|
-
logger.info('Add a "templates" section to your config with "templatesDir" and "outputDir"');
|
|
117280
|
-
return;
|
|
117281
|
-
}
|
|
117282
|
-
const templatesDir = options.templatesDir || this.configManager.resolvePath(templatesConfig.templatesDir);
|
|
117283
|
-
const outputDir = options.outputDir || this.configManager.resolvePath(templatesConfig.outputDir);
|
|
117284
|
-
if (!fs18.existsSync(templatesDir)) {
|
|
117844
|
+
const config = this.configManager.getConfig();
|
|
117845
|
+
const templatesDir = options.templatesDir || this.configManager.resolvePath(config.paths.templates);
|
|
117846
|
+
const outputDir = options.outputDir || this.configManager.resolvePath(config.paths.templatesOutput);
|
|
117847
|
+
if (!fs19.existsSync(templatesDir)) {
|
|
117285
117848
|
logger.error(`Templates directory not found: ${templatesDir}`);
|
|
117286
117849
|
return;
|
|
117287
117850
|
}
|
|
117288
|
-
|
|
117289
|
-
const
|
|
117290
|
-
|
|
117291
|
-
|
|
117292
|
-
|
|
117293
|
-
blockRegistry = new BlockRegistry(blocksOutputDir);
|
|
117294
|
-
await blockRegistry.loadBuiltBlocks();
|
|
117295
|
-
logger.info(`Loaded ${blockRegistry.getAllComponentMappings().length} built blocks`);
|
|
117296
|
-
}
|
|
117851
|
+
fs19.mkdirSync(outputDir, { recursive: true });
|
|
117852
|
+
const blocksOutputDir = this.configManager.resolvePath(config.paths.dist);
|
|
117853
|
+
const blockRegistry = new BlockRegistry(blocksOutputDir);
|
|
117854
|
+
await blockRegistry.loadBuiltBlocks();
|
|
117855
|
+
logger.info(`Loaded ${blockRegistry.getAllComponentMappings().length} built blocks`);
|
|
117297
117856
|
const renderer = new OfficialMDXRenderer({ blockRegistry });
|
|
117298
117857
|
renderer.initialize();
|
|
117299
117858
|
const templateFiles = this.findMDXFiles(templatesDir);
|
|
@@ -117306,8 +117865,8 @@ class BuildTemplatesCommand {
|
|
|
117306
117865
|
let errorCount = 0;
|
|
117307
117866
|
for (let i2 = 0;i2 < templateFiles.length; i2++) {
|
|
117308
117867
|
const templateFile = templateFiles[i2];
|
|
117309
|
-
const relativePath =
|
|
117310
|
-
const templateName =
|
|
117868
|
+
const relativePath = path23.relative(templatesDir, templateFile);
|
|
117869
|
+
const templateName = path23.basename(templateFile, ".mdx");
|
|
117311
117870
|
logger.step(i2 + 1, templateFiles.length, `Building template: ${relativePath}`);
|
|
117312
117871
|
try {
|
|
117313
117872
|
await this.buildTemplate(templateFile, templateName, outputDir, renderer);
|
|
@@ -117327,19 +117886,19 @@ class BuildTemplatesCommand {
|
|
|
117327
117886
|
}
|
|
117328
117887
|
}
|
|
117329
117888
|
async buildTemplate(templatePath, templateName, outputDir, renderer) {
|
|
117330
|
-
const mdxContent =
|
|
117889
|
+
const mdxContent = fs19.readFileSync(templatePath, "utf8");
|
|
117331
117890
|
const cleanContent = this.removeFrontmatter(mdxContent);
|
|
117332
117891
|
const html5 = await renderer.renderMDXToHTML(cleanContent);
|
|
117333
117892
|
const cleanHTML = renderer.postProcessHTML(html5);
|
|
117334
|
-
const outputPath =
|
|
117335
|
-
|
|
117336
|
-
logger.info(`✓ Generated: ${
|
|
117893
|
+
const outputPath = path23.join(outputDir, `${templateName}.html`);
|
|
117894
|
+
fs19.writeFileSync(outputPath, cleanHTML, "utf8");
|
|
117895
|
+
logger.info(`✓ Generated: ${path23.relative(process.cwd(), outputPath)}`);
|
|
117337
117896
|
}
|
|
117338
117897
|
findMDXFiles(dir) {
|
|
117339
117898
|
const files = [];
|
|
117340
|
-
const entries =
|
|
117899
|
+
const entries = fs19.readdirSync(dir, { withFileTypes: true });
|
|
117341
117900
|
for (const entry of entries) {
|
|
117342
|
-
const fullPath =
|
|
117901
|
+
const fullPath = path23.join(dir, entry.name);
|
|
117343
117902
|
if (entry.isDirectory()) {
|
|
117344
117903
|
files.push(...this.findMDXFiles(fullPath));
|
|
117345
117904
|
} else if (entry.isFile() && entry.name.endsWith(".mdx")) {
|
|
@@ -117354,6 +117913,69 @@ class BuildTemplatesCommand {
|
|
|
117354
117913
|
}
|
|
117355
117914
|
}
|
|
117356
117915
|
|
|
117916
|
+
// src/commands/env-command.ts
|
|
117917
|
+
import * as fs20 from "fs";
|
|
117918
|
+
import * as path24 from "path";
|
|
117919
|
+
class EnvCommand {
|
|
117920
|
+
configManager;
|
|
117921
|
+
constructor() {
|
|
117922
|
+
this.configManager = ConfigManager.getInstance();
|
|
117923
|
+
}
|
|
117924
|
+
getDockerEnvManager() {
|
|
117925
|
+
const config = this.configManager.getConfig();
|
|
117926
|
+
const packageJsonPath = path24.join(this.configManager.getConfigDir(), "package.json");
|
|
117927
|
+
let projectName = "wordpress-project";
|
|
117928
|
+
if (fs20.existsSync(packageJsonPath)) {
|
|
117929
|
+
try {
|
|
117930
|
+
const pkg = JSON.parse(fs20.readFileSync(packageJsonPath, "utf8"));
|
|
117931
|
+
projectName = pkg.name || projectName;
|
|
117932
|
+
} catch {}
|
|
117933
|
+
}
|
|
117934
|
+
return new DockerEnvManager({
|
|
117935
|
+
projectName,
|
|
117936
|
+
workspaceDir: this.configManager.getConfigDir(),
|
|
117937
|
+
config
|
|
117938
|
+
});
|
|
117939
|
+
}
|
|
117940
|
+
async destroy() {
|
|
117941
|
+
console.log(`
|
|
117942
|
+
\uD83D\uDDD1️ Destroying Docker environment...
|
|
117943
|
+
`);
|
|
117944
|
+
const manager = this.getDockerEnvManager();
|
|
117945
|
+
await manager.cleanup();
|
|
117946
|
+
console.log(`
|
|
117947
|
+
✅ Docker environment destroyed
|
|
117948
|
+
`);
|
|
117949
|
+
}
|
|
117950
|
+
async dbImport(filePath2) {
|
|
117951
|
+
const config = this.configManager.getConfig();
|
|
117952
|
+
const inputPath = filePath2 || config.dev.sqlDump;
|
|
117953
|
+
if (!inputPath) {
|
|
117954
|
+
throw new Error("No SQL file specified. Use --file option or set 'sqlDump' in config.");
|
|
117955
|
+
}
|
|
117956
|
+
console.log(`
|
|
117957
|
+
\uD83D\uDCE5 Importing database from ${inputPath}...
|
|
117958
|
+
`);
|
|
117959
|
+
const manager = this.getDockerEnvManager();
|
|
117960
|
+
await manager.importSqlDumpFromFile(inputPath);
|
|
117961
|
+
console.log(`
|
|
117962
|
+
✅ Database imported successfully
|
|
117963
|
+
`);
|
|
117964
|
+
}
|
|
117965
|
+
async dbExport(filePath2) {
|
|
117966
|
+
const config = this.configManager.getConfig();
|
|
117967
|
+
const outputPath = filePath2 || config.dev.sqlDump || "./db/dump.sql";
|
|
117968
|
+
console.log(`
|
|
117969
|
+
\uD83D\uDCE4 Exporting database to ${outputPath}...
|
|
117970
|
+
`);
|
|
117971
|
+
const manager = this.getDockerEnvManager();
|
|
117972
|
+
await manager.exportSqlDump(outputPath);
|
|
117973
|
+
console.log(`
|
|
117974
|
+
✅ Database exported successfully
|
|
117975
|
+
`);
|
|
117976
|
+
}
|
|
117977
|
+
}
|
|
117978
|
+
|
|
117357
117979
|
// src/index.ts
|
|
117358
117980
|
var program2 = new Command;
|
|
117359
117981
|
program2.name("wordpress-flow").description("Build WordPress sites with React, TypeScript, and MDX - A content-first development framework").version(package_default.version);
|
|
@@ -117438,7 +118060,7 @@ program2.command("build-templates").description("Build WordPress theme templates
|
|
|
117438
118060
|
process.exit(1);
|
|
117439
118061
|
}
|
|
117440
118062
|
});
|
|
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) => {
|
|
118063
|
+
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
118064
|
try {
|
|
117443
118065
|
await ensureConfiguration();
|
|
117444
118066
|
const command = new DevCommand;
|
|
@@ -117448,6 +118070,7 @@ program2.command("dev").description("Unified development mode - watches blocks,
|
|
|
117448
118070
|
concurrency: options.concurrency ? parseInt(options.concurrency, 10) : undefined,
|
|
117449
118071
|
push: options.push !== false,
|
|
117450
118072
|
templates: options.templates !== false,
|
|
118073
|
+
skipEnv: options.skipEnv || false,
|
|
117451
118074
|
verbose: options.verbose || false
|
|
117452
118075
|
});
|
|
117453
118076
|
} catch (error) {
|
|
@@ -117455,6 +118078,36 @@ program2.command("dev").description("Unified development mode - watches blocks,
|
|
|
117455
118078
|
process.exit(1);
|
|
117456
118079
|
}
|
|
117457
118080
|
});
|
|
118081
|
+
program2.command("destroy").description("Remove Docker containers and volumes for this project").action(async () => {
|
|
118082
|
+
try {
|
|
118083
|
+
await ensureConfiguration();
|
|
118084
|
+
const command = new EnvCommand;
|
|
118085
|
+
await command.destroy();
|
|
118086
|
+
} catch (error) {
|
|
118087
|
+
logger.error("Destroy command failed:", error);
|
|
118088
|
+
process.exit(1);
|
|
118089
|
+
}
|
|
118090
|
+
});
|
|
118091
|
+
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) => {
|
|
118092
|
+
try {
|
|
118093
|
+
await ensureConfiguration();
|
|
118094
|
+
const command = new EnvCommand;
|
|
118095
|
+
await command.dbImport(options.file);
|
|
118096
|
+
} catch (error) {
|
|
118097
|
+
logger.error("Database import failed:", error);
|
|
118098
|
+
process.exit(1);
|
|
118099
|
+
}
|
|
118100
|
+
});
|
|
118101
|
+
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) => {
|
|
118102
|
+
try {
|
|
118103
|
+
await ensureConfiguration();
|
|
118104
|
+
const command = new EnvCommand;
|
|
118105
|
+
await command.dbExport(options.file);
|
|
118106
|
+
} catch (error) {
|
|
118107
|
+
logger.error("Database export failed:", error);
|
|
118108
|
+
process.exit(1);
|
|
118109
|
+
}
|
|
118110
|
+
});
|
|
117458
118111
|
async function ensureConfiguration() {
|
|
117459
118112
|
const configManager = ConfigManager.getInstance();
|
|
117460
118113
|
if (!configManager.hasConfig()) {
|