@lark-apaas/fullstack-cli 1.1.70 → 1.1.71-alpha.20261103025257
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/README.md +10 -0
- package/dist/index.js +637 -235
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import fs33 from "fs";
|
|
3
|
+
import path28 from "path";
|
|
4
4
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
5
5
|
import { config as dotenvConfig } from "dotenv";
|
|
6
6
|
|
|
@@ -3493,9 +3493,9 @@ async function run3(options = {}) {
|
|
|
3493
3493
|
}
|
|
3494
3494
|
|
|
3495
3495
|
// src/commands/upgrade/deps/run.handler.ts
|
|
3496
|
-
import { spawnSync as
|
|
3497
|
-
import
|
|
3498
|
-
import
|
|
3496
|
+
import { spawnSync as spawnSync6 } from "child_process";
|
|
3497
|
+
import fs15 from "fs";
|
|
3498
|
+
import path12 from "path";
|
|
3499
3499
|
|
|
3500
3500
|
// src/utils/grayscale/config.ts
|
|
3501
3501
|
function getGrayscaleConfig(configJson) {
|
|
@@ -3656,11 +3656,317 @@ function resolveGrayscaleVersions(_cwd, configJson) {
|
|
|
3656
3656
|
return versions;
|
|
3657
3657
|
}
|
|
3658
3658
|
|
|
3659
|
+
// src/commands/upgrade/deps/drizzle-peer-migration.ts
|
|
3660
|
+
import { spawnSync as spawnSync4 } from "child_process";
|
|
3661
|
+
import fs13 from "fs";
|
|
3662
|
+
import path10 from "path";
|
|
3663
|
+
var dataPaasSdks = /* @__PURE__ */ new Set([
|
|
3664
|
+
"@lark-apaas/fullstack-nestjs-core",
|
|
3665
|
+
"@lark-apaas/nestjs-datapaas",
|
|
3666
|
+
"@lark-apaas/express-core",
|
|
3667
|
+
"@lark-apaas/express-datapaas"
|
|
3668
|
+
]);
|
|
3669
|
+
var versionPattern = /^(\d+)\.(\d+)\.(\d+)(?:-([\da-zA-Z.-]+))?(?:\+[\da-zA-Z.-]+)?$/;
|
|
3670
|
+
function compareVersions(a, b) {
|
|
3671
|
+
const left = a.match(versionPattern);
|
|
3672
|
+
const right = b.match(versionPattern);
|
|
3673
|
+
for (let index = 1; index <= 3; index++) {
|
|
3674
|
+
const difference = Number(left[index]) - Number(right[index]);
|
|
3675
|
+
if (difference) return difference;
|
|
3676
|
+
}
|
|
3677
|
+
if (!left[4] || !right[4]) return Number(!left[4]) - Number(!right[4]);
|
|
3678
|
+
const leftParts = left[4].split(".");
|
|
3679
|
+
const rightParts = right[4].split(".");
|
|
3680
|
+
for (let index = 0; index < Math.max(leftParts.length, rightParts.length); index++) {
|
|
3681
|
+
const l = leftParts[index];
|
|
3682
|
+
const r = rightParts[index];
|
|
3683
|
+
if (l === r) continue;
|
|
3684
|
+
if (l === void 0 || r === void 0) return l === void 0 ? -1 : 1;
|
|
3685
|
+
const lNumeric = /^\d+$/.test(l);
|
|
3686
|
+
const rNumeric = /^\d+$/.test(r);
|
|
3687
|
+
if (lNumeric && rNumeric) return Number(l) - Number(r);
|
|
3688
|
+
if (lNumeric !== rNumeric) return lNumeric ? -1 : 1;
|
|
3689
|
+
return l < r ? -1 : 1;
|
|
3690
|
+
}
|
|
3691
|
+
return 0;
|
|
3692
|
+
}
|
|
3693
|
+
function readPublishedSdk(pkg2, selector, cwd) {
|
|
3694
|
+
const result = spawnSync4(
|
|
3695
|
+
"npm",
|
|
3696
|
+
["view", `${pkg2}@${selector}`, "version", "peerDependencies", "--json"],
|
|
3697
|
+
{
|
|
3698
|
+
cwd,
|
|
3699
|
+
encoding: "utf8",
|
|
3700
|
+
timeout: 3e4,
|
|
3701
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
3702
|
+
}
|
|
3703
|
+
);
|
|
3704
|
+
if (result.error || result.status !== 0) {
|
|
3705
|
+
throw new Error(
|
|
3706
|
+
`Cannot resolve Drizzle peer for ${pkg2}@${selector}: ${result.error?.message ?? `npm view exited ${result.status}`}`
|
|
3707
|
+
);
|
|
3708
|
+
}
|
|
3709
|
+
let metadata;
|
|
3710
|
+
try {
|
|
3711
|
+
metadata = JSON.parse(result.stdout?.toString() || "null");
|
|
3712
|
+
} catch {
|
|
3713
|
+
throw new Error(`Invalid npm metadata for ${pkg2}@${selector}`);
|
|
3714
|
+
}
|
|
3715
|
+
const candidates = (Array.isArray(metadata) ? metadata : [metadata]).map(
|
|
3716
|
+
(candidate) => typeof candidate === "string" ? { version: candidate } : candidate
|
|
3717
|
+
);
|
|
3718
|
+
if (!candidates.length || candidates.some(
|
|
3719
|
+
(candidate) => !candidate || typeof candidate.version !== "string" || !versionPattern.test(candidate.version)
|
|
3720
|
+
)) {
|
|
3721
|
+
throw new Error(`Missing published version for ${pkg2}@${selector}`);
|
|
3722
|
+
}
|
|
3723
|
+
return candidates.sort((a, b) => compareVersions(a.version, b.version)).pop();
|
|
3724
|
+
}
|
|
3725
|
+
function planDrizzlePeerMigration(targets, manifest, cwd, onlyIfPeerNeedsRepair = false) {
|
|
3726
|
+
if (!targets.some((target) => dataPaasSdks.has(target.pkg))) return void 0;
|
|
3727
|
+
const selected = new Map(targets.map((target) => [target.pkg, target.version]));
|
|
3728
|
+
const publishedTargets = new Map(
|
|
3729
|
+
targets.filter((target) => isRegistrySelector(target.version)).map((target) => [
|
|
3730
|
+
target.pkg,
|
|
3731
|
+
readPublishedSdk(target.pkg, target.version, cwd)
|
|
3732
|
+
])
|
|
3733
|
+
);
|
|
3734
|
+
for (const target of targets) {
|
|
3735
|
+
if (dataPaasSdks.has(target.pkg) && !isRegistrySelector(target.version))
|
|
3736
|
+
throw new Error(
|
|
3737
|
+
`Cannot resolve published Drizzle peer for non-registry SDK ${target.pkg}@${target.version}`
|
|
3738
|
+
);
|
|
3739
|
+
}
|
|
3740
|
+
const declared = { ...manifest.devDependencies, ...manifest.dependencies };
|
|
3741
|
+
const peers = /* @__PURE__ */ new Map();
|
|
3742
|
+
for (const pkg2 of dataPaasSdks) {
|
|
3743
|
+
const selector = selected.get(pkg2) ?? declared[pkg2];
|
|
3744
|
+
if (!selector) continue;
|
|
3745
|
+
let sdk = publishedTargets.get(pkg2);
|
|
3746
|
+
if (!selected.has(pkg2)) {
|
|
3747
|
+
sdk = readRetainedSdk(pkg2, cwd);
|
|
3748
|
+
}
|
|
3749
|
+
sdk ?? (sdk = readPublishedSdk(pkg2, selector, cwd));
|
|
3750
|
+
const peer2 = sdk.peerDependencies?.["drizzle-orm"];
|
|
3751
|
+
if (typeof peer2 !== "string" || !versionPattern.test(peer2)) {
|
|
3752
|
+
throw new Error(
|
|
3753
|
+
`${pkg2}@${sdk.version} must declare an exact drizzle-orm peer; received ${String(peer2)}`
|
|
3754
|
+
);
|
|
3755
|
+
}
|
|
3756
|
+
peers.set(pkg2, peer2);
|
|
3757
|
+
}
|
|
3758
|
+
const versions = new Set(peers.values());
|
|
3759
|
+
if (versions.size !== 1) {
|
|
3760
|
+
throw new Error(
|
|
3761
|
+
`Incompatible Drizzle peers: ${[...peers].map(([pkg2, peer2]) => `${pkg2} requires ${peer2}`).join(", ")}. Upgrade the affected SDKs together.`
|
|
3762
|
+
);
|
|
3763
|
+
}
|
|
3764
|
+
const peer = [...versions][0];
|
|
3765
|
+
if (onlyIfPeerNeedsRepair && peerIsConsistent(manifest, peer, cwd))
|
|
3766
|
+
return void 0;
|
|
3767
|
+
console.log(
|
|
3768
|
+
`[fullstack-cli] Drizzle peer migration: ${declared["drizzle-orm"] ?? "(not declared)"} -> ${peer}`
|
|
3769
|
+
);
|
|
3770
|
+
return [
|
|
3771
|
+
...targets.map(
|
|
3772
|
+
(target) => `${target.pkg}@${publishedTargets.has(target.pkg) ? installSelector(target.version, publishedTargets.get(target.pkg).version) : target.version}`
|
|
3773
|
+
),
|
|
3774
|
+
`drizzle-orm@=${peer}`
|
|
3775
|
+
];
|
|
3776
|
+
}
|
|
3777
|
+
function readRetainedSdk(pkg2, cwd) {
|
|
3778
|
+
const installed = readOptionalJson(
|
|
3779
|
+
path10.join(cwd, "node_modules", pkg2, "package.json")
|
|
3780
|
+
);
|
|
3781
|
+
if (installed) {
|
|
3782
|
+
if (typeof installed.version !== "string" || !versionPattern.test(installed.version))
|
|
3783
|
+
throw new Error(`Invalid installed SDK metadata for ${pkg2}`);
|
|
3784
|
+
return installed;
|
|
3785
|
+
}
|
|
3786
|
+
const lock = readOptionalJson(path10.join(cwd, "package-lock.json"));
|
|
3787
|
+
const locked = lock?.packages?.[`node_modules/${pkg2}`]?.version ?? lock?.dependencies?.[pkg2]?.version;
|
|
3788
|
+
return typeof locked === "string" && versionPattern.test(locked) ? readPublishedSdk(pkg2, locked, cwd) : void 0;
|
|
3789
|
+
}
|
|
3790
|
+
function readOptionalJson(filename) {
|
|
3791
|
+
try {
|
|
3792
|
+
return JSON.parse(fs13.readFileSync(filename, "utf8"));
|
|
3793
|
+
} catch (error) {
|
|
3794
|
+
if (error.code === "ENOENT") return void 0;
|
|
3795
|
+
throw new Error(`Cannot read retained dependency metadata at ${filename}`);
|
|
3796
|
+
}
|
|
3797
|
+
}
|
|
3798
|
+
function installSelector(requested, resolved) {
|
|
3799
|
+
if (requested.startsWith("^") || requested.startsWith("~"))
|
|
3800
|
+
return `${requested[0]}${resolved}`;
|
|
3801
|
+
if (versionPattern.test(requested) || /^[a-zA-Z][\w.-]*$/.test(requested) || requested === "*")
|
|
3802
|
+
return resolved;
|
|
3803
|
+
return `${requested} >=${resolved}`;
|
|
3804
|
+
}
|
|
3805
|
+
function isRegistrySelector(selector) {
|
|
3806
|
+
return !/^(?:[a-z][\w+.-]*:|\.?\.?\/|\/|git@)/i.test(selector) && !selector.includes("/") && selector !== "." && selector !== "..";
|
|
3807
|
+
}
|
|
3808
|
+
function peerIsConsistent(manifest, peer, cwd) {
|
|
3809
|
+
const declarations = [
|
|
3810
|
+
manifest.dependencies?.["drizzle-orm"],
|
|
3811
|
+
manifest.devDependencies?.["drizzle-orm"]
|
|
3812
|
+
].filter(Boolean);
|
|
3813
|
+
if (!declarations.length || declarations.some((version) => version !== peer && version !== `=${peer}`))
|
|
3814
|
+
return false;
|
|
3815
|
+
try {
|
|
3816
|
+
const installed = JSON.parse(
|
|
3817
|
+
fs13.readFileSync(
|
|
3818
|
+
path10.join(cwd, "node_modules/drizzle-orm/package.json"),
|
|
3819
|
+
"utf8"
|
|
3820
|
+
)
|
|
3821
|
+
);
|
|
3822
|
+
if (installed.version !== peer) return false;
|
|
3823
|
+
const lockPath = path10.join(cwd, "package-lock.json");
|
|
3824
|
+
if (fs13.existsSync(lockPath)) {
|
|
3825
|
+
const lock = JSON.parse(fs13.readFileSync(lockPath, "utf8"));
|
|
3826
|
+
if ((lock.packages?.["node_modules/drizzle-orm"]?.version ?? lock.dependencies?.["drizzle-orm"]?.version) !== peer)
|
|
3827
|
+
return false;
|
|
3828
|
+
}
|
|
3829
|
+
return true;
|
|
3830
|
+
} catch {
|
|
3831
|
+
return false;
|
|
3832
|
+
}
|
|
3833
|
+
}
|
|
3834
|
+
|
|
3835
|
+
// src/commands/upgrade/deps/apply-drizzle-peer-migration.ts
|
|
3836
|
+
import { spawnSync as spawnSync5 } from "child_process";
|
|
3837
|
+
import fs14 from "fs";
|
|
3838
|
+
import path11 from "path";
|
|
3839
|
+
var affectedPackages = [
|
|
3840
|
+
"@lark-apaas/fullstack-nestjs-core",
|
|
3841
|
+
"@lark-apaas/nestjs-datapaas",
|
|
3842
|
+
"@lark-apaas/express-core",
|
|
3843
|
+
"@lark-apaas/express-datapaas",
|
|
3844
|
+
"drizzle-orm"
|
|
3845
|
+
];
|
|
3846
|
+
function applyDrizzlePeerMigration(targets, cwd) {
|
|
3847
|
+
const manifestPath = path11.join(cwd, "package.json");
|
|
3848
|
+
const lockPath = path11.join(cwd, "package-lock.json");
|
|
3849
|
+
const modulesPath = path11.join(cwd, "node_modules");
|
|
3850
|
+
const backup = path11.join(cwd, ".fullstack-cli-peer-migration");
|
|
3851
|
+
if (fs14.existsSync(path11.join(cwd, "npm-shrinkwrap.json"))) {
|
|
3852
|
+
throw new Error(
|
|
3853
|
+
"Drizzle peer migration requires package-lock.json; migrate npm-shrinkwrap.json manually before upgrading SDKs."
|
|
3854
|
+
);
|
|
3855
|
+
}
|
|
3856
|
+
const originalManifest = fs14.readFileSync(manifestPath);
|
|
3857
|
+
const originalLock = fs14.existsSync(lockPath) ? fs14.readFileSync(lockPath) : void 0;
|
|
3858
|
+
const manifest = JSON.parse(originalManifest.toString());
|
|
3859
|
+
const lock = originalLock ? JSON.parse(originalLock.toString()) : void 0;
|
|
3860
|
+
if (lock && (![2, 3].includes(lock.lockfileVersion) || !lock.packages || typeof lock.packages !== "object" || Array.isArray(lock.packages))) {
|
|
3861
|
+
throw new Error(
|
|
3862
|
+
"Drizzle peer migration requires npm lockfileVersion 2 or 3; regenerate the lockfile with the current SDKs before upgrading."
|
|
3863
|
+
);
|
|
3864
|
+
}
|
|
3865
|
+
const peerTarget = targets.find((target) => target.startsWith("drizzle-orm@="));
|
|
3866
|
+
if (!peerTarget)
|
|
3867
|
+
throw new Error("Missing resolved Drizzle peer migration target");
|
|
3868
|
+
const peer = peerTarget.slice("drizzle-orm@=".length);
|
|
3869
|
+
let declared = false;
|
|
3870
|
+
for (const section of ["dependencies", "devDependencies"]) {
|
|
3871
|
+
if (manifest[section]?.["drizzle-orm"] !== void 0) {
|
|
3872
|
+
manifest[section]["drizzle-orm"] = peer;
|
|
3873
|
+
declared = true;
|
|
3874
|
+
}
|
|
3875
|
+
}
|
|
3876
|
+
if (!declared) (manifest.dependencies ?? (manifest.dependencies = {}))["drizzle-orm"] = peer;
|
|
3877
|
+
if (lock) {
|
|
3878
|
+
const selectedNames = new Set(
|
|
3879
|
+
targets.map(
|
|
3880
|
+
(target) => target.slice(0, target.indexOf("@", target.startsWith("@") ? 1 : 0))
|
|
3881
|
+
)
|
|
3882
|
+
);
|
|
3883
|
+
const retainedNames = affectedPackages.filter(
|
|
3884
|
+
(name) => name !== "drizzle-orm" && !selectedNames.has(name) && [
|
|
3885
|
+
"dependencies",
|
|
3886
|
+
"devDependencies",
|
|
3887
|
+
"optionalDependencies",
|
|
3888
|
+
"peerDependencies"
|
|
3889
|
+
].some((section) => manifest[section]?.[name] !== void 0)
|
|
3890
|
+
);
|
|
3891
|
+
const retainedRoots = retainedNames.map((name) => `node_modules/${name}`);
|
|
3892
|
+
const removedRoots = Object.keys(lock.packages).filter(
|
|
3893
|
+
(key) => !retainedRoots.some(
|
|
3894
|
+
(root) => key === root || key.startsWith(`${root}/`)
|
|
3895
|
+
) && affectedPackages.some(
|
|
3896
|
+
(name) => key === `node_modules/${name}` || key.endsWith(`/node_modules/${name}`)
|
|
3897
|
+
)
|
|
3898
|
+
);
|
|
3899
|
+
for (const key of Object.keys(lock.packages)) {
|
|
3900
|
+
if (removedRoots.some((root) => key === root || key.startsWith(`${root}/`)))
|
|
3901
|
+
delete lock.packages[key];
|
|
3902
|
+
}
|
|
3903
|
+
if (lock.lockfileVersion === 2 && lock.dependencies) {
|
|
3904
|
+
for (const name of affectedPackages) {
|
|
3905
|
+
if (!retainedNames.includes(name)) delete lock.dependencies[name];
|
|
3906
|
+
}
|
|
3907
|
+
}
|
|
3908
|
+
}
|
|
3909
|
+
try {
|
|
3910
|
+
fs14.mkdirSync(backup);
|
|
3911
|
+
} catch {
|
|
3912
|
+
throw new Error(
|
|
3913
|
+
`Cannot start migration; inspect the existing recovery directory ${backup} before retrying.`
|
|
3914
|
+
);
|
|
3915
|
+
}
|
|
3916
|
+
fs14.writeFileSync(path11.join(backup, "package.json"), originalManifest);
|
|
3917
|
+
if (originalLock)
|
|
3918
|
+
fs14.writeFileSync(path11.join(backup, "package-lock.json"), originalLock);
|
|
3919
|
+
const hadModules = fs14.existsSync(modulesPath);
|
|
3920
|
+
let movedModules = false;
|
|
3921
|
+
try {
|
|
3922
|
+
if (hadModules) {
|
|
3923
|
+
fs14.renameSync(modulesPath, path11.join(backup, "node_modules"));
|
|
3924
|
+
movedModules = true;
|
|
3925
|
+
}
|
|
3926
|
+
fs14.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + "\n");
|
|
3927
|
+
if (lock) fs14.writeFileSync(lockPath, JSON.stringify(lock, null, 2) + "\n");
|
|
3928
|
+
const sdkTargets = targets.filter((target) => target !== peerTarget);
|
|
3929
|
+
runNpm(
|
|
3930
|
+
["install", "--package-lock-only", "--ignore-scripts", ...sdkTargets],
|
|
3931
|
+
cwd
|
|
3932
|
+
);
|
|
3933
|
+
runNpm(["ci"], cwd);
|
|
3934
|
+
} catch (error) {
|
|
3935
|
+
try {
|
|
3936
|
+
if (movedModules || !hadModules)
|
|
3937
|
+
fs14.rmSync(modulesPath, { recursive: true, force: true });
|
|
3938
|
+
if (movedModules)
|
|
3939
|
+
fs14.renameSync(path11.join(backup, "node_modules"), modulesPath);
|
|
3940
|
+
fs14.writeFileSync(manifestPath, originalManifest);
|
|
3941
|
+
if (originalLock) fs14.writeFileSync(lockPath, originalLock);
|
|
3942
|
+
else fs14.rmSync(lockPath, { force: true });
|
|
3943
|
+
fs14.rmSync(backup, { recursive: true, force: true });
|
|
3944
|
+
} catch {
|
|
3945
|
+
throw new Error(
|
|
3946
|
+
`Drizzle migration failed; recovery files were preserved at ${backup}. Restore package.json, package-lock.json and node_modules before retrying.`
|
|
3947
|
+
);
|
|
3948
|
+
}
|
|
3949
|
+
throw error;
|
|
3950
|
+
}
|
|
3951
|
+
fs14.rmSync(backup, { recursive: true, force: true });
|
|
3952
|
+
}
|
|
3953
|
+
function runNpm(args, cwd) {
|
|
3954
|
+
const result = spawnSync5("npm", args, { cwd, stdio: "inherit" });
|
|
3955
|
+
if (result.error || result.status !== 0)
|
|
3956
|
+
throw new Error(
|
|
3957
|
+
`Drizzle migration npm ${args[0]} failed: ${result.error?.message ?? `exit ${result.status}`}`
|
|
3958
|
+
);
|
|
3959
|
+
}
|
|
3960
|
+
|
|
3659
3961
|
// src/commands/upgrade/deps/run.handler.ts
|
|
3660
3962
|
function parseSemver(version) {
|
|
3661
3963
|
const match = version.match(/^(\d+)\.(\d+)\.(\d+)/);
|
|
3662
3964
|
if (!match) return null;
|
|
3663
|
-
return [
|
|
3965
|
+
return [
|
|
3966
|
+
parseInt(match[1], 10),
|
|
3967
|
+
parseInt(match[2], 10),
|
|
3968
|
+
parseInt(match[3], 10)
|
|
3969
|
+
];
|
|
3664
3970
|
}
|
|
3665
3971
|
function compareSemver(a, b) {
|
|
3666
3972
|
const va = parseSemver(a);
|
|
@@ -3708,13 +4014,37 @@ function findLarkAapaasPackages(cwd, filterPackages) {
|
|
|
3708
4014
|
}
|
|
3709
4015
|
return packages;
|
|
3710
4016
|
}
|
|
3711
|
-
function upgradePackages(packages, version, cwd) {
|
|
4017
|
+
function upgradePackages(packages, version, cwd, dryRun = false) {
|
|
4018
|
+
const manifest = readPackageJson(cwd);
|
|
4019
|
+
const declared = { ...manifest.devDependencies, ...manifest.dependencies };
|
|
4020
|
+
const migration = planDrizzlePeerMigration(
|
|
4021
|
+
packages.map((pkg2) => ({ pkg: pkg2, version: version || declared[pkg2] })),
|
|
4022
|
+
manifest,
|
|
4023
|
+
cwd
|
|
4024
|
+
);
|
|
4025
|
+
if (migration) {
|
|
4026
|
+
console.log(
|
|
4027
|
+
`[fullstack-cli] ${dryRun ? "Would install" : "Installing"} ${migration.join(" ")}`
|
|
4028
|
+
);
|
|
4029
|
+
if (dryRun) return;
|
|
4030
|
+
applyDrizzlePeerMigration(migration, cwd);
|
|
4031
|
+
return;
|
|
4032
|
+
}
|
|
4033
|
+
if (dryRun) {
|
|
4034
|
+
console.log(
|
|
4035
|
+
"[fullstack-cli] Dry run mode: would upgrade via npm update (no grayscale)"
|
|
4036
|
+
);
|
|
4037
|
+
packages.forEach(
|
|
4038
|
+
(pkg2) => console.log(` - ${pkg2} -> ${version || "latest compatible"}`)
|
|
4039
|
+
);
|
|
4040
|
+
return;
|
|
4041
|
+
}
|
|
3712
4042
|
if (version) {
|
|
3713
4043
|
console.log(`[fullstack-cli] Upgrading to version ${version}...`);
|
|
3714
4044
|
packages.forEach((pkg2) => {
|
|
3715
4045
|
const target = `${pkg2}@${version}`;
|
|
3716
4046
|
console.log(`[fullstack-cli] Installing ${target}...`);
|
|
3717
|
-
const result =
|
|
4047
|
+
const result = spawnSync6("npm", ["install", target], {
|
|
3718
4048
|
cwd,
|
|
3719
4049
|
stdio: "inherit"
|
|
3720
4050
|
});
|
|
@@ -3726,7 +4056,7 @@ function upgradePackages(packages, version, cwd) {
|
|
|
3726
4056
|
console.log("[fullstack-cli] Upgrading to latest compatible versions...");
|
|
3727
4057
|
packages.forEach((pkg2) => {
|
|
3728
4058
|
console.log(`[fullstack-cli] Updating ${pkg2}...`);
|
|
3729
|
-
const result =
|
|
4059
|
+
const result = spawnSync6("npm", ["update", pkg2], {
|
|
3730
4060
|
cwd,
|
|
3731
4061
|
stdio: "inherit"
|
|
3732
4062
|
});
|
|
@@ -3738,34 +4068,54 @@ function upgradePackages(packages, version, cwd) {
|
|
|
3738
4068
|
}
|
|
3739
4069
|
function installGrayscaleVersions(packages, grayscaleVersions, cwd, dryRun, mode) {
|
|
3740
4070
|
const upgradePlan = [];
|
|
4071
|
+
const selectedVersions = /* @__PURE__ */ new Map();
|
|
3741
4072
|
for (const pkg2 of packages) {
|
|
3742
4073
|
const version = grayscaleVersions.get(pkg2);
|
|
3743
4074
|
if (version) {
|
|
4075
|
+
selectedVersions.set(pkg2, version);
|
|
3744
4076
|
let current = "";
|
|
3745
4077
|
try {
|
|
3746
|
-
const installedPkgPath =
|
|
3747
|
-
|
|
4078
|
+
const installedPkgPath = path12.join(
|
|
4079
|
+
cwd,
|
|
4080
|
+
"node_modules",
|
|
4081
|
+
pkg2,
|
|
4082
|
+
"package.json"
|
|
4083
|
+
);
|
|
4084
|
+
const installedPkg = JSON.parse(
|
|
4085
|
+
fs15.readFileSync(installedPkgPath, "utf-8")
|
|
4086
|
+
);
|
|
3748
4087
|
current = installedPkg.version || "";
|
|
3749
4088
|
} catch (err) {
|
|
3750
4089
|
const code = err?.code;
|
|
3751
4090
|
if (code !== "ENOENT") {
|
|
3752
|
-
console.warn(
|
|
4091
|
+
console.warn(
|
|
4092
|
+
`[fullstack-cli] Failed to read installed version of ${pkg2}: ${err instanceof Error ? err.message : String(err)}`
|
|
4093
|
+
);
|
|
3753
4094
|
}
|
|
3754
4095
|
}
|
|
3755
4096
|
if (mode === "destroy") {
|
|
3756
4097
|
if (!isRangeVersion(version) && current === version) {
|
|
3757
|
-
|
|
4098
|
+
selectedVersions.set(pkg2, current);
|
|
4099
|
+
console.log(
|
|
4100
|
+
`[fullstack-cli] ${pkg2}@${version} (already installed, skip)`
|
|
4101
|
+
);
|
|
3758
4102
|
continue;
|
|
3759
4103
|
}
|
|
3760
4104
|
} else {
|
|
3761
4105
|
if (isRangeVersion(version)) {
|
|
3762
4106
|
if (current && satisfiesCaret(current, version)) {
|
|
3763
|
-
|
|
4107
|
+
selectedVersions.set(pkg2, current);
|
|
4108
|
+
console.log(
|
|
4109
|
+
`[fullstack-cli] ${pkg2}@${current} satisfies ${version} (skip)`
|
|
4110
|
+
);
|
|
3764
4111
|
continue;
|
|
3765
4112
|
}
|
|
3766
4113
|
} else {
|
|
3767
4114
|
if (current === version) {
|
|
3768
|
-
|
|
4115
|
+
selectedVersions.set(pkg2, current);
|
|
4116
|
+
console.log(
|
|
4117
|
+
`[fullstack-cli] ${pkg2}@${version} (already installed, skip)`
|
|
4118
|
+
);
|
|
3769
4119
|
continue;
|
|
3770
4120
|
}
|
|
3771
4121
|
}
|
|
@@ -3773,11 +4123,25 @@ function installGrayscaleVersions(packages, grayscaleVersions, cwd, dryRun, mode
|
|
|
3773
4123
|
upgradePlan.push({ pkg: pkg2, version, current });
|
|
3774
4124
|
}
|
|
3775
4125
|
}
|
|
3776
|
-
|
|
3777
|
-
|
|
4126
|
+
const selectedTargets = packages.flatMap((pkg2) => {
|
|
4127
|
+
const version = selectedVersions.get(pkg2);
|
|
4128
|
+
return version ? [{ pkg: pkg2, version }] : [];
|
|
4129
|
+
});
|
|
4130
|
+
const migration = planDrizzlePeerMigration(
|
|
4131
|
+
selectedTargets,
|
|
4132
|
+
readPackageJson(cwd),
|
|
4133
|
+
cwd,
|
|
4134
|
+
upgradePlan.length === 0
|
|
4135
|
+
);
|
|
4136
|
+
if (upgradePlan.length === 0 && !migration) {
|
|
4137
|
+
console.log(
|
|
4138
|
+
"[fullstack-cli] No grayscale versions matched current packages"
|
|
4139
|
+
);
|
|
3778
4140
|
return;
|
|
3779
4141
|
}
|
|
3780
|
-
console.log(
|
|
4142
|
+
console.log(
|
|
4143
|
+
`[fullstack-cli] Grayscale upgrade plan (${upgradePlan.length} package(s)):`
|
|
4144
|
+
);
|
|
3781
4145
|
upgradePlan.forEach(({ pkg: pkg2, version, current }) => {
|
|
3782
4146
|
console.log(` - ${pkg2} ${current} -> ${version}`);
|
|
3783
4147
|
});
|
|
@@ -3785,63 +4149,101 @@ function installGrayscaleVersions(packages, grayscaleVersions, cwd, dryRun, mode
|
|
|
3785
4149
|
console.log("[fullstack-cli] Dry run mode, skipping actual installation");
|
|
3786
4150
|
return;
|
|
3787
4151
|
}
|
|
3788
|
-
const targets = upgradePlan.map(({ pkg: pkg2, version }) => `${pkg2}@${version}`);
|
|
4152
|
+
const targets = migration ?? upgradePlan.map(({ pkg: pkg2, version }) => `${pkg2}@${version}`);
|
|
3789
4153
|
console.log(`[fullstack-cli] Installing ${targets.join(" ")}...`);
|
|
3790
|
-
|
|
4154
|
+
if (migration) {
|
|
4155
|
+
applyDrizzlePeerMigration(migration, cwd);
|
|
4156
|
+
return;
|
|
4157
|
+
}
|
|
4158
|
+
const result = spawnSync6("npm", ["install", ...targets], {
|
|
3791
4159
|
cwd,
|
|
3792
4160
|
stdio: "inherit"
|
|
3793
4161
|
});
|
|
3794
4162
|
if (result.error || result.status !== 0) {
|
|
3795
|
-
|
|
4163
|
+
throw new Error(
|
|
4164
|
+
`npm install failed: ${result.error?.message ?? `exit ${result.status}`}`
|
|
4165
|
+
);
|
|
3796
4166
|
}
|
|
3797
4167
|
}
|
|
3798
4168
|
async function run4(options = {}) {
|
|
3799
4169
|
const cwd = process.env.INIT_CWD || process.cwd();
|
|
3800
4170
|
console.log("[fullstack-cli] Starting dependencies upgrade...");
|
|
3801
4171
|
try {
|
|
3802
|
-
console.log(
|
|
4172
|
+
console.log(
|
|
4173
|
+
"[fullstack-cli] Step 1/3: Scanning @lark-apaas dependencies..."
|
|
4174
|
+
);
|
|
3803
4175
|
const packages = findLarkAapaasPackages(cwd, options.packages);
|
|
3804
4176
|
if (packages.length === 0) {
|
|
3805
4177
|
console.log("[fullstack-cli] No @lark-apaas packages found");
|
|
3806
4178
|
return;
|
|
3807
4179
|
}
|
|
3808
|
-
console.log(
|
|
4180
|
+
console.log(
|
|
4181
|
+
`[fullstack-cli] Found ${packages.length} @lark-apaas package(s):`
|
|
4182
|
+
);
|
|
3809
4183
|
packages.forEach((p) => console.log(` - ${p}`));
|
|
3810
4184
|
if (options.skipGrayscale) {
|
|
3811
|
-
console.log(
|
|
4185
|
+
console.log(
|
|
4186
|
+
"[fullstack-cli] Step 2/3: Skipping grayscale check (--skip-grayscale)"
|
|
4187
|
+
);
|
|
3812
4188
|
} else if (options.version) {
|
|
3813
|
-
console.log(
|
|
4189
|
+
console.log(
|
|
4190
|
+
"[fullstack-cli] Step 2/3: Skipping grayscale check (explicit --version provided)"
|
|
4191
|
+
);
|
|
3814
4192
|
} else if (!options.grayscaleConfig) {
|
|
3815
|
-
console.log(
|
|
4193
|
+
console.log(
|
|
4194
|
+
"[fullstack-cli] Step 2/3: No grayscale config, falling back to default upgrade"
|
|
4195
|
+
);
|
|
3816
4196
|
} else {
|
|
3817
4197
|
console.log("[fullstack-cli] Step 2/3: Checking grayscale config...");
|
|
3818
4198
|
try {
|
|
3819
|
-
const grayscaleVersions = resolveGrayscaleVersions(
|
|
4199
|
+
const grayscaleVersions = resolveGrayscaleVersions(
|
|
4200
|
+
cwd,
|
|
4201
|
+
options.grayscaleConfig
|
|
4202
|
+
);
|
|
3820
4203
|
if (grayscaleVersions) {
|
|
3821
|
-
console.log(
|
|
3822
|
-
|
|
4204
|
+
console.log(
|
|
4205
|
+
"[fullstack-cli] Step 3/3: Applying grayscale versions..."
|
|
4206
|
+
);
|
|
4207
|
+
installGrayscaleVersions(
|
|
4208
|
+
packages,
|
|
4209
|
+
grayscaleVersions,
|
|
4210
|
+
cwd,
|
|
4211
|
+
!!options.dryRun,
|
|
4212
|
+
options.mode || "rebuild"
|
|
4213
|
+
);
|
|
3823
4214
|
if (!options.dryRun) {
|
|
3824
|
-
console.log(
|
|
3825
|
-
|
|
4215
|
+
console.log(
|
|
4216
|
+
`[fullstack-cli] \u2713 Successfully upgraded ${packages.length} package(s) via grayscale`
|
|
4217
|
+
);
|
|
4218
|
+
console.log(
|
|
4219
|
+
"[fullstack-cli] Dependencies upgrade completed successfully \u2705"
|
|
4220
|
+
);
|
|
3826
4221
|
}
|
|
3827
4222
|
} else {
|
|
3828
|
-
console.log(
|
|
4223
|
+
console.log(
|
|
4224
|
+
"[fullstack-cli] Grayscale config provided but not available, skip upgrade"
|
|
4225
|
+
);
|
|
3829
4226
|
}
|
|
3830
4227
|
} catch (error) {
|
|
3831
4228
|
const msg = error instanceof Error ? error.message : String(error);
|
|
3832
|
-
console.warn(
|
|
4229
|
+
console.warn(
|
|
4230
|
+
`[fullstack-cli] Grayscale check failed: ${msg}, skip upgrade`
|
|
4231
|
+
);
|
|
3833
4232
|
}
|
|
3834
4233
|
return;
|
|
3835
4234
|
}
|
|
3836
4235
|
if (options.dryRun) {
|
|
3837
|
-
|
|
3838
|
-
packages.forEach((p) => console.log(` - ${p} -> ${options.version || "latest compatible"}`));
|
|
4236
|
+
upgradePackages(packages, options.version, cwd, true);
|
|
3839
4237
|
return;
|
|
3840
4238
|
}
|
|
3841
4239
|
console.log("[fullstack-cli] Step 3/3: Upgrading packages...");
|
|
3842
4240
|
upgradePackages(packages, options.version, cwd);
|
|
3843
|
-
console.log(
|
|
3844
|
-
|
|
4241
|
+
console.log(
|
|
4242
|
+
`[fullstack-cli] \u2713 Successfully upgraded ${packages.length} package(s)`
|
|
4243
|
+
);
|
|
4244
|
+
console.log(
|
|
4245
|
+
"[fullstack-cli] Dependencies upgrade completed successfully \u2705"
|
|
4246
|
+
);
|
|
3845
4247
|
} catch (error) {
|
|
3846
4248
|
const message = error instanceof Error ? error.message : String(error);
|
|
3847
4249
|
console.error("[fullstack-cli] Failed to upgrade dependencies:", message);
|
|
@@ -3861,9 +4263,9 @@ var depsCommand = {
|
|
|
3861
4263
|
};
|
|
3862
4264
|
|
|
3863
4265
|
// src/commands/upgrade/global-deps/run.handler.ts
|
|
3864
|
-
import { spawnSync as
|
|
3865
|
-
import
|
|
3866
|
-
import
|
|
4266
|
+
import { spawnSync as spawnSync7 } from "child_process";
|
|
4267
|
+
import fs16 from "fs";
|
|
4268
|
+
import path13 from "path";
|
|
3867
4269
|
var MANAGED_GLOBAL_CLIS = [
|
|
3868
4270
|
"@lark-apaas/fullstack-cli",
|
|
3869
4271
|
"@lark-apaas/miaoda-cli"
|
|
@@ -3874,15 +4276,15 @@ function readGlobalInstalledVersion(pkg2) {
|
|
|
3874
4276
|
if (process.env.NPM_CONFIG_PREFIX) candidates.push(process.env.NPM_CONFIG_PREFIX);
|
|
3875
4277
|
candidates.push("/usr");
|
|
3876
4278
|
candidates.push("/usr/local");
|
|
3877
|
-
if (process.env.HOME) candidates.push(
|
|
4279
|
+
if (process.env.HOME) candidates.push(path13.join(process.env.HOME, ".npm-global"));
|
|
3878
4280
|
const seen = /* @__PURE__ */ new Set();
|
|
3879
4281
|
for (const prefix of candidates) {
|
|
3880
4282
|
if (seen.has(prefix)) continue;
|
|
3881
4283
|
seen.add(prefix);
|
|
3882
4284
|
try {
|
|
3883
|
-
const pkgPath =
|
|
3884
|
-
if (
|
|
3885
|
-
const meta = JSON.parse(
|
|
4285
|
+
const pkgPath = path13.join(prefix, "lib", "node_modules", pkg2, "package.json");
|
|
4286
|
+
if (fs16.existsSync(pkgPath)) {
|
|
4287
|
+
const meta = JSON.parse(fs16.readFileSync(pkgPath, "utf-8"));
|
|
3886
4288
|
if (meta && typeof meta.version === "string") return meta.version;
|
|
3887
4289
|
}
|
|
3888
4290
|
} catch (err) {
|
|
@@ -3940,7 +4342,7 @@ async function run5(options = {}) {
|
|
|
3940
4342
|
npmArgs.push("--registry", options.registry);
|
|
3941
4343
|
}
|
|
3942
4344
|
console.log(`[fullstack-cli] Running: npm ${npmArgs.join(" ")}`);
|
|
3943
|
-
const result =
|
|
4345
|
+
const result = spawnSync7("npm", npmArgs, { stdio: "inherit" });
|
|
3944
4346
|
if (result.error || result.status !== 0) {
|
|
3945
4347
|
console.warn(
|
|
3946
4348
|
`[fullstack-cli] npm install -g failed: ${result.error?.message ?? `exit ${result.status}`}`
|
|
@@ -3979,9 +4381,9 @@ var upgradeCommand = {
|
|
|
3979
4381
|
};
|
|
3980
4382
|
|
|
3981
4383
|
// src/commands/action-plugin/utils.ts
|
|
3982
|
-
import
|
|
3983
|
-
import
|
|
3984
|
-
import { spawnSync as
|
|
4384
|
+
import fs17 from "fs";
|
|
4385
|
+
import path14 from "path";
|
|
4386
|
+
import { spawnSync as spawnSync8, execSync as execSync2 } from "child_process";
|
|
3985
4387
|
function parsePluginName(input) {
|
|
3986
4388
|
const match = input.match(/^(@[^/]+\/[^@]+)(?:@(.+))?$/);
|
|
3987
4389
|
if (!match) {
|
|
@@ -3998,18 +4400,18 @@ function getProjectRoot() {
|
|
|
3998
4400
|
return process.cwd();
|
|
3999
4401
|
}
|
|
4000
4402
|
function getPackageJsonPath() {
|
|
4001
|
-
return
|
|
4403
|
+
return path14.join(getProjectRoot(), "package.json");
|
|
4002
4404
|
}
|
|
4003
4405
|
function getPluginPath(pluginName) {
|
|
4004
|
-
return
|
|
4406
|
+
return path14.join(getProjectRoot(), "node_modules", pluginName);
|
|
4005
4407
|
}
|
|
4006
4408
|
function readPackageJson2() {
|
|
4007
4409
|
const pkgPath = getPackageJsonPath();
|
|
4008
|
-
if (!
|
|
4410
|
+
if (!fs17.existsSync(pkgPath)) {
|
|
4009
4411
|
throw new Error("package.json not found in current directory");
|
|
4010
4412
|
}
|
|
4011
4413
|
try {
|
|
4012
|
-
const content =
|
|
4414
|
+
const content = fs17.readFileSync(pkgPath, "utf-8");
|
|
4013
4415
|
return JSON.parse(content);
|
|
4014
4416
|
} catch {
|
|
4015
4417
|
throw new Error("Failed to parse package.json");
|
|
@@ -4017,7 +4419,7 @@ function readPackageJson2() {
|
|
|
4017
4419
|
}
|
|
4018
4420
|
function writePackageJson2(pkg2) {
|
|
4019
4421
|
const pkgPath = getPackageJsonPath();
|
|
4020
|
-
|
|
4422
|
+
fs17.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
|
|
4021
4423
|
}
|
|
4022
4424
|
function readActionPlugins() {
|
|
4023
4425
|
const pkg2 = readPackageJson2();
|
|
@@ -4038,7 +4440,7 @@ function getInstalledPluginVersion(pluginName) {
|
|
|
4038
4440
|
}
|
|
4039
4441
|
function npmInstall(tgzPath) {
|
|
4040
4442
|
console.log(`[action-plugin] Running npm install ${tgzPath}...`);
|
|
4041
|
-
const result =
|
|
4443
|
+
const result = spawnSync8("npm", ["install", tgzPath, "--no-save", "--no-package-lock", "--ignore-scripts"], {
|
|
4042
4444
|
cwd: getProjectRoot(),
|
|
4043
4445
|
stdio: "inherit"
|
|
4044
4446
|
});
|
|
@@ -4050,12 +4452,12 @@ function npmInstall(tgzPath) {
|
|
|
4050
4452
|
}
|
|
4051
4453
|
}
|
|
4052
4454
|
function getPackageVersion(pluginName) {
|
|
4053
|
-
const pkgJsonPath =
|
|
4054
|
-
if (!
|
|
4455
|
+
const pkgJsonPath = path14.join(getPluginPath(pluginName), "package.json");
|
|
4456
|
+
if (!fs17.existsSync(pkgJsonPath)) {
|
|
4055
4457
|
return null;
|
|
4056
4458
|
}
|
|
4057
4459
|
try {
|
|
4058
|
-
const content =
|
|
4460
|
+
const content = fs17.readFileSync(pkgJsonPath, "utf-8");
|
|
4059
4461
|
const pkg2 = JSON.parse(content);
|
|
4060
4462
|
return pkg2.version || null;
|
|
4061
4463
|
} catch {
|
|
@@ -4063,49 +4465,49 @@ function getPackageVersion(pluginName) {
|
|
|
4063
4465
|
}
|
|
4064
4466
|
}
|
|
4065
4467
|
function readPluginPackageJson(pluginPath) {
|
|
4066
|
-
const pkgJsonPath =
|
|
4067
|
-
if (!
|
|
4468
|
+
const pkgJsonPath = path14.join(pluginPath, "package.json");
|
|
4469
|
+
if (!fs17.existsSync(pkgJsonPath)) {
|
|
4068
4470
|
return null;
|
|
4069
4471
|
}
|
|
4070
4472
|
try {
|
|
4071
|
-
const content =
|
|
4473
|
+
const content = fs17.readFileSync(pkgJsonPath, "utf-8");
|
|
4072
4474
|
return JSON.parse(content);
|
|
4073
4475
|
} catch {
|
|
4074
4476
|
return null;
|
|
4075
4477
|
}
|
|
4076
4478
|
}
|
|
4077
4479
|
function extractTgzToNodeModules(tgzPath, pluginName) {
|
|
4078
|
-
const nodeModulesPath =
|
|
4079
|
-
const targetDir =
|
|
4080
|
-
const scopeDir =
|
|
4081
|
-
if (!
|
|
4082
|
-
|
|
4480
|
+
const nodeModulesPath = path14.join(getProjectRoot(), "node_modules");
|
|
4481
|
+
const targetDir = path14.join(nodeModulesPath, pluginName);
|
|
4482
|
+
const scopeDir = path14.dirname(targetDir);
|
|
4483
|
+
if (!fs17.existsSync(scopeDir)) {
|
|
4484
|
+
fs17.mkdirSync(scopeDir, { recursive: true });
|
|
4083
4485
|
}
|
|
4084
|
-
if (
|
|
4085
|
-
|
|
4486
|
+
if (fs17.existsSync(targetDir)) {
|
|
4487
|
+
fs17.rmSync(targetDir, { recursive: true });
|
|
4086
4488
|
}
|
|
4087
|
-
const tempDir =
|
|
4088
|
-
if (
|
|
4089
|
-
|
|
4489
|
+
const tempDir = path14.join(nodeModulesPath, ".cache", "fullstack-cli", "extract-temp");
|
|
4490
|
+
if (fs17.existsSync(tempDir)) {
|
|
4491
|
+
fs17.rmSync(tempDir, { recursive: true });
|
|
4090
4492
|
}
|
|
4091
|
-
|
|
4493
|
+
fs17.mkdirSync(tempDir, { recursive: true });
|
|
4092
4494
|
try {
|
|
4093
4495
|
execSync2(`tar -xzf "${tgzPath}" -C "${tempDir}"`, { stdio: "pipe" });
|
|
4094
|
-
const extractedDir =
|
|
4095
|
-
if (
|
|
4096
|
-
|
|
4496
|
+
const extractedDir = path14.join(tempDir, "package");
|
|
4497
|
+
if (fs17.existsSync(extractedDir)) {
|
|
4498
|
+
fs17.renameSync(extractedDir, targetDir);
|
|
4097
4499
|
} else {
|
|
4098
|
-
const files =
|
|
4500
|
+
const files = fs17.readdirSync(tempDir);
|
|
4099
4501
|
if (files.length === 1) {
|
|
4100
|
-
|
|
4502
|
+
fs17.renameSync(path14.join(tempDir, files[0]), targetDir);
|
|
4101
4503
|
} else {
|
|
4102
4504
|
throw new Error("Unexpected tgz structure");
|
|
4103
4505
|
}
|
|
4104
4506
|
}
|
|
4105
4507
|
return targetDir;
|
|
4106
4508
|
} finally {
|
|
4107
|
-
if (
|
|
4108
|
-
|
|
4509
|
+
if (fs17.existsSync(tempDir)) {
|
|
4510
|
+
fs17.rmSync(tempDir, { recursive: true });
|
|
4109
4511
|
}
|
|
4110
4512
|
}
|
|
4111
4513
|
}
|
|
@@ -4114,10 +4516,10 @@ function checkMissingPeerDeps(peerDeps) {
|
|
|
4114
4516
|
return [];
|
|
4115
4517
|
}
|
|
4116
4518
|
const missing = [];
|
|
4117
|
-
const nodeModulesPath =
|
|
4519
|
+
const nodeModulesPath = path14.join(getProjectRoot(), "node_modules");
|
|
4118
4520
|
for (const [depName, _version] of Object.entries(peerDeps)) {
|
|
4119
|
-
const depPath =
|
|
4120
|
-
if (!
|
|
4521
|
+
const depPath = path14.join(nodeModulesPath, depName);
|
|
4522
|
+
if (!fs17.existsSync(depPath)) {
|
|
4121
4523
|
missing.push(depName);
|
|
4122
4524
|
}
|
|
4123
4525
|
}
|
|
@@ -4128,7 +4530,7 @@ function installMissingDeps(deps) {
|
|
|
4128
4530
|
return;
|
|
4129
4531
|
}
|
|
4130
4532
|
console.log(`[action-plugin] Installing missing dependencies: ${deps.join(", ")}`);
|
|
4131
|
-
const result =
|
|
4533
|
+
const result = spawnSync8("npm", ["install", ...deps, "--no-save", "--no-package-lock"], {
|
|
4132
4534
|
cwd: getProjectRoot(),
|
|
4133
4535
|
stdio: "inherit"
|
|
4134
4536
|
});
|
|
@@ -4141,16 +4543,16 @@ function installMissingDeps(deps) {
|
|
|
4141
4543
|
}
|
|
4142
4544
|
function removePluginDirectory(pluginName) {
|
|
4143
4545
|
const pluginPath = getPluginPath(pluginName);
|
|
4144
|
-
if (
|
|
4145
|
-
|
|
4546
|
+
if (fs17.existsSync(pluginPath)) {
|
|
4547
|
+
fs17.rmSync(pluginPath, { recursive: true });
|
|
4146
4548
|
console.log(`[action-plugin] Removed ${pluginName}`);
|
|
4147
4549
|
}
|
|
4148
4550
|
}
|
|
4149
4551
|
|
|
4150
4552
|
// src/commands/action-plugin/api-client.ts
|
|
4151
4553
|
import { HttpClient as HttpClient2 } from "@lark-apaas/http-client";
|
|
4152
|
-
import
|
|
4153
|
-
import
|
|
4554
|
+
import fs18 from "fs";
|
|
4555
|
+
import path15 from "path";
|
|
4154
4556
|
var PLUGIN_CACHE_DIR = "node_modules/.cache/fullstack-cli/plugins";
|
|
4155
4557
|
async function getPluginVersions(keys, latestOnly = true) {
|
|
4156
4558
|
const client = getHttpClient();
|
|
@@ -4215,19 +4617,19 @@ async function downloadFromPublic(downloadURL) {
|
|
|
4215
4617
|
return Buffer.from(arrayBuffer);
|
|
4216
4618
|
}
|
|
4217
4619
|
function getPluginCacheDir() {
|
|
4218
|
-
return
|
|
4620
|
+
return path15.join(process.cwd(), PLUGIN_CACHE_DIR);
|
|
4219
4621
|
}
|
|
4220
4622
|
function ensureCacheDir() {
|
|
4221
4623
|
const cacheDir = getPluginCacheDir();
|
|
4222
|
-
if (!
|
|
4223
|
-
|
|
4624
|
+
if (!fs18.existsSync(cacheDir)) {
|
|
4625
|
+
fs18.mkdirSync(cacheDir, { recursive: true });
|
|
4224
4626
|
}
|
|
4225
4627
|
}
|
|
4226
4628
|
function getTempFilePath(pluginKey, version) {
|
|
4227
4629
|
ensureCacheDir();
|
|
4228
4630
|
const safeKey = pluginKey.replace(/[/@]/g, "_");
|
|
4229
4631
|
const filename = `${safeKey}@${version}.tgz`;
|
|
4230
|
-
return
|
|
4632
|
+
return path15.join(getPluginCacheDir(), filename);
|
|
4231
4633
|
}
|
|
4232
4634
|
var MAX_RETRIES = 2;
|
|
4233
4635
|
async function withRetry(operation, description, maxRetries = MAX_RETRIES) {
|
|
@@ -4264,7 +4666,7 @@ async function downloadPlugin(pluginKey, requestedVersion) {
|
|
|
4264
4666
|
);
|
|
4265
4667
|
}
|
|
4266
4668
|
const tgzPath = getTempFilePath(pluginKey, pluginInfo.version);
|
|
4267
|
-
|
|
4669
|
+
fs18.writeFileSync(tgzPath, tgzBuffer);
|
|
4268
4670
|
console.log(`[action-plugin] Downloaded to ${tgzPath} (${(tgzBuffer.length / 1024).toFixed(2)} KB)`);
|
|
4269
4671
|
return {
|
|
4270
4672
|
tgzPath,
|
|
@@ -4278,18 +4680,18 @@ function getCachePath(pluginKey, version) {
|
|
|
4278
4680
|
ensureCacheDir();
|
|
4279
4681
|
const safeKey = pluginKey.replace(/[/@]/g, "_");
|
|
4280
4682
|
const filename = `${safeKey}@${version}.tgz`;
|
|
4281
|
-
return
|
|
4683
|
+
return path15.join(getPluginCacheDir(), filename);
|
|
4282
4684
|
}
|
|
4283
4685
|
function hasCachedPlugin(pluginKey, version) {
|
|
4284
4686
|
const cachePath = getCachePath(pluginKey, version);
|
|
4285
|
-
return
|
|
4687
|
+
return fs18.existsSync(cachePath);
|
|
4286
4688
|
}
|
|
4287
4689
|
function listCachedPlugins() {
|
|
4288
4690
|
const cacheDir = getPluginCacheDir();
|
|
4289
|
-
if (!
|
|
4691
|
+
if (!fs18.existsSync(cacheDir)) {
|
|
4290
4692
|
return [];
|
|
4291
4693
|
}
|
|
4292
|
-
const files =
|
|
4694
|
+
const files = fs18.readdirSync(cacheDir);
|
|
4293
4695
|
const result = [];
|
|
4294
4696
|
for (const file of files) {
|
|
4295
4697
|
if (!file.endsWith(".tgz")) continue;
|
|
@@ -4297,8 +4699,8 @@ function listCachedPlugins() {
|
|
|
4297
4699
|
if (!match) continue;
|
|
4298
4700
|
const [, rawName, version] = match;
|
|
4299
4701
|
const name = rawName.replace(/^_/, "@").replace(/_/, "/");
|
|
4300
|
-
const filePath =
|
|
4301
|
-
const stat =
|
|
4702
|
+
const filePath = path15.join(cacheDir, file);
|
|
4703
|
+
const stat = fs18.statSync(filePath);
|
|
4302
4704
|
result.push({
|
|
4303
4705
|
name,
|
|
4304
4706
|
version,
|
|
@@ -4311,14 +4713,14 @@ function listCachedPlugins() {
|
|
|
4311
4713
|
}
|
|
4312
4714
|
function cleanAllCache() {
|
|
4313
4715
|
const cacheDir = getPluginCacheDir();
|
|
4314
|
-
if (!
|
|
4716
|
+
if (!fs18.existsSync(cacheDir)) {
|
|
4315
4717
|
return 0;
|
|
4316
4718
|
}
|
|
4317
|
-
const files =
|
|
4719
|
+
const files = fs18.readdirSync(cacheDir);
|
|
4318
4720
|
let count = 0;
|
|
4319
4721
|
for (const file of files) {
|
|
4320
4722
|
if (file.endsWith(".tgz")) {
|
|
4321
|
-
|
|
4723
|
+
fs18.unlinkSync(path15.join(cacheDir, file));
|
|
4322
4724
|
count++;
|
|
4323
4725
|
}
|
|
4324
4726
|
}
|
|
@@ -4326,21 +4728,21 @@ function cleanAllCache() {
|
|
|
4326
4728
|
}
|
|
4327
4729
|
function cleanPluginCache(pluginKey, version) {
|
|
4328
4730
|
const cacheDir = getPluginCacheDir();
|
|
4329
|
-
if (!
|
|
4731
|
+
if (!fs18.existsSync(cacheDir)) {
|
|
4330
4732
|
return 0;
|
|
4331
4733
|
}
|
|
4332
4734
|
const safeKey = pluginKey.replace(/[/@]/g, "_");
|
|
4333
|
-
const files =
|
|
4735
|
+
const files = fs18.readdirSync(cacheDir);
|
|
4334
4736
|
let count = 0;
|
|
4335
4737
|
for (const file of files) {
|
|
4336
4738
|
if (version) {
|
|
4337
4739
|
if (file === `${safeKey}@${version}.tgz`) {
|
|
4338
|
-
|
|
4740
|
+
fs18.unlinkSync(path15.join(cacheDir, file));
|
|
4339
4741
|
count++;
|
|
4340
4742
|
}
|
|
4341
4743
|
} else {
|
|
4342
4744
|
if (file.startsWith(`${safeKey}@`) && file.endsWith(".tgz")) {
|
|
4343
|
-
|
|
4745
|
+
fs18.unlinkSync(path15.join(cacheDir, file));
|
|
4344
4746
|
count++;
|
|
4345
4747
|
}
|
|
4346
4748
|
}
|
|
@@ -4767,45 +5169,45 @@ var actionPluginCommandGroup = {
|
|
|
4767
5169
|
};
|
|
4768
5170
|
|
|
4769
5171
|
// src/commands/capability/utils.ts
|
|
4770
|
-
import
|
|
5172
|
+
import fs19 from "fs";
|
|
4771
5173
|
import { createRequire as createRequire2 } from "module";
|
|
4772
|
-
import
|
|
5174
|
+
import path16 from "path";
|
|
4773
5175
|
var CAPABILITIES_DIR = "server/capabilities";
|
|
4774
5176
|
var SHARED_CAPABILITIES_DIR = "shared/capabilities";
|
|
4775
5177
|
function getProjectRoot2() {
|
|
4776
5178
|
return process.cwd();
|
|
4777
5179
|
}
|
|
4778
5180
|
function getCapabilitiesDir() {
|
|
4779
|
-
const sharedDir =
|
|
4780
|
-
if (
|
|
5181
|
+
const sharedDir = path16.join(getProjectRoot2(), SHARED_CAPABILITIES_DIR);
|
|
5182
|
+
if (fs19.existsSync(sharedDir)) {
|
|
4781
5183
|
return sharedDir;
|
|
4782
5184
|
}
|
|
4783
|
-
return
|
|
5185
|
+
return path16.join(getProjectRoot2(), CAPABILITIES_DIR);
|
|
4784
5186
|
}
|
|
4785
5187
|
function getCapabilityPath(id) {
|
|
4786
|
-
return
|
|
5188
|
+
return path16.join(getCapabilitiesDir(), `${id}.json`);
|
|
4787
5189
|
}
|
|
4788
5190
|
function getPluginManifestPath(pluginKey) {
|
|
4789
|
-
return
|
|
5191
|
+
return path16.join(getProjectRoot2(), "node_modules", pluginKey, "manifest.json");
|
|
4790
5192
|
}
|
|
4791
5193
|
function capabilitiesDirExists() {
|
|
4792
|
-
return
|
|
5194
|
+
return fs19.existsSync(getCapabilitiesDir());
|
|
4793
5195
|
}
|
|
4794
5196
|
function listCapabilityIds() {
|
|
4795
5197
|
const dir = getCapabilitiesDir();
|
|
4796
|
-
if (!
|
|
5198
|
+
if (!fs19.existsSync(dir)) {
|
|
4797
5199
|
return [];
|
|
4798
5200
|
}
|
|
4799
|
-
const files =
|
|
5201
|
+
const files = fs19.readdirSync(dir);
|
|
4800
5202
|
return files.filter((f) => f.endsWith(".json") && f !== "capabilities.json").map((f) => f.replace(/\.json$/, ""));
|
|
4801
5203
|
}
|
|
4802
5204
|
function readCapability(id) {
|
|
4803
5205
|
const filePath = getCapabilityPath(id);
|
|
4804
|
-
if (!
|
|
5206
|
+
if (!fs19.existsSync(filePath)) {
|
|
4805
5207
|
throw new Error(`Capability not found: ${id}`);
|
|
4806
5208
|
}
|
|
4807
5209
|
try {
|
|
4808
|
-
const content =
|
|
5210
|
+
const content = fs19.readFileSync(filePath, "utf-8");
|
|
4809
5211
|
return JSON.parse(content);
|
|
4810
5212
|
} catch (error) {
|
|
4811
5213
|
if (error instanceof SyntaxError) {
|
|
@@ -4832,11 +5234,11 @@ function readAllCapabilities() {
|
|
|
4832
5234
|
}
|
|
4833
5235
|
function readPluginManifest(pluginKey) {
|
|
4834
5236
|
const manifestPath = getPluginManifestPath(pluginKey);
|
|
4835
|
-
if (!
|
|
5237
|
+
if (!fs19.existsSync(manifestPath)) {
|
|
4836
5238
|
throw new Error(`Plugin not installed: ${pluginKey} (manifest.json not found)`);
|
|
4837
5239
|
}
|
|
4838
5240
|
try {
|
|
4839
|
-
const content =
|
|
5241
|
+
const content = fs19.readFileSync(manifestPath, "utf-8");
|
|
4840
5242
|
return JSON.parse(content);
|
|
4841
5243
|
} catch (error) {
|
|
4842
5244
|
if (error instanceof SyntaxError) {
|
|
@@ -4853,7 +5255,7 @@ function hasValidParamsSchema(paramsSchema) {
|
|
|
4853
5255
|
}
|
|
4854
5256
|
async function loadPlugin(pluginKey) {
|
|
4855
5257
|
try {
|
|
4856
|
-
const userRequire = createRequire2(
|
|
5258
|
+
const userRequire = createRequire2(path16.join(getProjectRoot2(), "package.json"));
|
|
4857
5259
|
const resolvedPath = userRequire.resolve(pluginKey);
|
|
4858
5260
|
const pluginModule = await import(resolvedPath);
|
|
4859
5261
|
const pluginPackage = pluginModule.default ?? pluginModule;
|
|
@@ -5016,8 +5418,8 @@ var capabilityCommandGroup = {
|
|
|
5016
5418
|
import { execFile } from "child_process";
|
|
5017
5419
|
|
|
5018
5420
|
// src/commands/component/registry-preparer.ts
|
|
5019
|
-
import
|
|
5020
|
-
import
|
|
5421
|
+
import fs20 from "fs";
|
|
5422
|
+
import path17 from "path";
|
|
5021
5423
|
import os from "os";
|
|
5022
5424
|
|
|
5023
5425
|
// src/commands/component/service.ts
|
|
@@ -5077,7 +5479,7 @@ async function sendInstallEvent(key) {
|
|
|
5077
5479
|
}
|
|
5078
5480
|
|
|
5079
5481
|
// src/commands/component/registry-preparer.ts
|
|
5080
|
-
var REGISTRY_TEMP_DIR =
|
|
5482
|
+
var REGISTRY_TEMP_DIR = path17.join(os.tmpdir(), "miaoda-registry");
|
|
5081
5483
|
function parseComponentKey(key) {
|
|
5082
5484
|
const match = key.match(/^@([^/]+)\/(.+)$/);
|
|
5083
5485
|
if (!match) {
|
|
@@ -5089,11 +5491,11 @@ function parseComponentKey(key) {
|
|
|
5089
5491
|
}
|
|
5090
5492
|
function getLocalRegistryPath(key) {
|
|
5091
5493
|
const { scope, name } = parseComponentKey(key);
|
|
5092
|
-
return
|
|
5494
|
+
return path17.join(REGISTRY_TEMP_DIR, scope, `${name}.json`);
|
|
5093
5495
|
}
|
|
5094
5496
|
function ensureDir(dirPath) {
|
|
5095
|
-
if (!
|
|
5096
|
-
|
|
5497
|
+
if (!fs20.existsSync(dirPath)) {
|
|
5498
|
+
fs20.mkdirSync(dirPath, { recursive: true });
|
|
5097
5499
|
}
|
|
5098
5500
|
}
|
|
5099
5501
|
async function prepareRecursive(key, visited) {
|
|
@@ -5126,8 +5528,8 @@ async function prepareRecursive(key, visited) {
|
|
|
5126
5528
|
registryDependencies: deps.map((dep) => getLocalRegistryPath(dep))
|
|
5127
5529
|
};
|
|
5128
5530
|
const localPath = getLocalRegistryPath(key);
|
|
5129
|
-
ensureDir(
|
|
5130
|
-
|
|
5531
|
+
ensureDir(path17.dirname(localPath));
|
|
5532
|
+
fs20.writeFileSync(localPath, JSON.stringify(rewrittenItem, null, 2), "utf-8");
|
|
5131
5533
|
debug("\u4FDD\u5B58\u5230: %s", localPath);
|
|
5132
5534
|
}
|
|
5133
5535
|
async function prepareComponentRegistryItems(id) {
|
|
@@ -5137,18 +5539,18 @@ async function prepareComponentRegistryItems(id) {
|
|
|
5137
5539
|
}
|
|
5138
5540
|
function cleanupTempDir() {
|
|
5139
5541
|
try {
|
|
5140
|
-
if (
|
|
5141
|
-
|
|
5542
|
+
if (fs20.existsSync(REGISTRY_TEMP_DIR)) {
|
|
5543
|
+
fs20.rmSync(REGISTRY_TEMP_DIR, { recursive: true, force: true });
|
|
5142
5544
|
}
|
|
5143
5545
|
} catch {
|
|
5144
5546
|
}
|
|
5145
5547
|
}
|
|
5146
5548
|
function getDownloadedRegistryItem(itemId) {
|
|
5147
5549
|
const localPath = getLocalRegistryPath(itemId);
|
|
5148
|
-
if (!
|
|
5550
|
+
if (!fs20.existsSync(localPath)) {
|
|
5149
5551
|
return null;
|
|
5150
5552
|
}
|
|
5151
|
-
const content =
|
|
5553
|
+
const content = fs20.readFileSync(localPath, "utf-8");
|
|
5152
5554
|
return JSON.parse(content);
|
|
5153
5555
|
}
|
|
5154
5556
|
|
|
@@ -5316,58 +5718,58 @@ var componentCommandGroup = {
|
|
|
5316
5718
|
};
|
|
5317
5719
|
|
|
5318
5720
|
// src/commands/migration/version-manager.ts
|
|
5319
|
-
import
|
|
5320
|
-
import
|
|
5721
|
+
import fs21 from "fs";
|
|
5722
|
+
import path18 from "path";
|
|
5321
5723
|
var PACKAGE_JSON = "package.json";
|
|
5322
5724
|
var VERSION_FIELD = "migrationVersion";
|
|
5323
5725
|
function getPackageJsonPath2() {
|
|
5324
|
-
return
|
|
5726
|
+
return path18.join(process.cwd(), PACKAGE_JSON);
|
|
5325
5727
|
}
|
|
5326
5728
|
function getCurrentVersion() {
|
|
5327
5729
|
const pkgPath = getPackageJsonPath2();
|
|
5328
|
-
if (!
|
|
5730
|
+
if (!fs21.existsSync(pkgPath)) {
|
|
5329
5731
|
throw new Error("package.json not found");
|
|
5330
5732
|
}
|
|
5331
|
-
const pkg2 = JSON.parse(
|
|
5733
|
+
const pkg2 = JSON.parse(fs21.readFileSync(pkgPath, "utf-8"));
|
|
5332
5734
|
return pkg2[VERSION_FIELD] ?? 0;
|
|
5333
5735
|
}
|
|
5334
5736
|
function setCurrentVersion(version) {
|
|
5335
5737
|
const pkgPath = getPackageJsonPath2();
|
|
5336
|
-
const pkg2 = JSON.parse(
|
|
5738
|
+
const pkg2 = JSON.parse(fs21.readFileSync(pkgPath, "utf-8"));
|
|
5337
5739
|
pkg2[VERSION_FIELD] = version;
|
|
5338
|
-
|
|
5740
|
+
fs21.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
|
|
5339
5741
|
}
|
|
5340
5742
|
|
|
5341
5743
|
// src/commands/migration/versions/v001_capability/json-migrator/detector.ts
|
|
5342
|
-
import
|
|
5343
|
-
import
|
|
5744
|
+
import fs23 from "fs";
|
|
5745
|
+
import path20 from "path";
|
|
5344
5746
|
|
|
5345
5747
|
// src/commands/migration/versions/v001_capability/utils.ts
|
|
5346
|
-
import
|
|
5347
|
-
import
|
|
5748
|
+
import fs22 from "fs";
|
|
5749
|
+
import path19 from "path";
|
|
5348
5750
|
var CAPABILITIES_DIR2 = "server/capabilities";
|
|
5349
5751
|
function getProjectRoot3() {
|
|
5350
5752
|
return process.cwd();
|
|
5351
5753
|
}
|
|
5352
5754
|
function getCapabilitiesDir2() {
|
|
5353
|
-
return
|
|
5755
|
+
return path19.join(getProjectRoot3(), CAPABILITIES_DIR2);
|
|
5354
5756
|
}
|
|
5355
5757
|
function getPluginManifestPath2(pluginKey) {
|
|
5356
|
-
return
|
|
5758
|
+
return path19.join(getProjectRoot3(), "node_modules", pluginKey, "manifest.json");
|
|
5357
5759
|
}
|
|
5358
5760
|
|
|
5359
5761
|
// src/commands/migration/versions/v001_capability/json-migrator/detector.ts
|
|
5360
5762
|
function detectJsonMigration() {
|
|
5361
5763
|
const capabilitiesDir = getCapabilitiesDir2();
|
|
5362
|
-
const oldFilePath =
|
|
5363
|
-
if (!
|
|
5764
|
+
const oldFilePath = path20.join(capabilitiesDir, "capabilities.json");
|
|
5765
|
+
if (!fs23.existsSync(oldFilePath)) {
|
|
5364
5766
|
return {
|
|
5365
5767
|
needsMigration: false,
|
|
5366
5768
|
reason: "capabilities.json not found"
|
|
5367
5769
|
};
|
|
5368
5770
|
}
|
|
5369
5771
|
try {
|
|
5370
|
-
const content =
|
|
5772
|
+
const content = fs23.readFileSync(oldFilePath, "utf-8");
|
|
5371
5773
|
const parsed = JSON.parse(content);
|
|
5372
5774
|
if (!Array.isArray(parsed)) {
|
|
5373
5775
|
return {
|
|
@@ -5418,8 +5820,8 @@ async function check(options) {
|
|
|
5418
5820
|
}
|
|
5419
5821
|
|
|
5420
5822
|
// src/commands/migration/versions/v001_capability/json-migrator/index.ts
|
|
5421
|
-
import
|
|
5422
|
-
import
|
|
5823
|
+
import fs24 from "fs";
|
|
5824
|
+
import path21 from "path";
|
|
5423
5825
|
|
|
5424
5826
|
// src/commands/migration/versions/v001_capability/mapping.ts
|
|
5425
5827
|
var DEFAULT_PLUGIN_VERSION = "1.0.0";
|
|
@@ -5649,18 +6051,18 @@ function transformCapabilities(oldCapabilities) {
|
|
|
5649
6051
|
// src/commands/migration/versions/v001_capability/json-migrator/index.ts
|
|
5650
6052
|
function loadExistingCapabilities() {
|
|
5651
6053
|
const capabilitiesDir = getCapabilitiesDir2();
|
|
5652
|
-
if (!
|
|
6054
|
+
if (!fs24.existsSync(capabilitiesDir)) {
|
|
5653
6055
|
return [];
|
|
5654
6056
|
}
|
|
5655
|
-
const files =
|
|
6057
|
+
const files = fs24.readdirSync(capabilitiesDir);
|
|
5656
6058
|
const capabilities = [];
|
|
5657
6059
|
for (const file of files) {
|
|
5658
6060
|
if (file === "capabilities.json" || !file.endsWith(".json")) {
|
|
5659
6061
|
continue;
|
|
5660
6062
|
}
|
|
5661
6063
|
try {
|
|
5662
|
-
const filePath =
|
|
5663
|
-
const content =
|
|
6064
|
+
const filePath = path21.join(capabilitiesDir, file);
|
|
6065
|
+
const content = fs24.readFileSync(filePath, "utf-8");
|
|
5664
6066
|
const capability = JSON.parse(content);
|
|
5665
6067
|
if (capability.id && capability.pluginKey) {
|
|
5666
6068
|
capabilities.push(capability);
|
|
@@ -5718,9 +6120,9 @@ async function migrateJsonFiles(options) {
|
|
|
5718
6120
|
}
|
|
5719
6121
|
const capabilitiesDir = getCapabilitiesDir2();
|
|
5720
6122
|
for (const cap of newCapabilities) {
|
|
5721
|
-
const filePath =
|
|
6123
|
+
const filePath = path21.join(capabilitiesDir, `${cap.id}.json`);
|
|
5722
6124
|
const content = JSON.stringify(cap, null, 2);
|
|
5723
|
-
|
|
6125
|
+
fs24.writeFileSync(filePath, content, "utf-8");
|
|
5724
6126
|
console.log(` \u2713 Created: ${cap.id}.json`);
|
|
5725
6127
|
}
|
|
5726
6128
|
return {
|
|
@@ -5732,11 +6134,11 @@ async function migrateJsonFiles(options) {
|
|
|
5732
6134
|
}
|
|
5733
6135
|
|
|
5734
6136
|
// src/commands/migration/versions/v001_capability/plugin-installer/detector.ts
|
|
5735
|
-
import
|
|
6137
|
+
import fs25 from "fs";
|
|
5736
6138
|
function isPluginInstalled2(pluginKey) {
|
|
5737
6139
|
const actionPlugins = readActionPlugins();
|
|
5738
6140
|
const manifestPath = getPluginManifestPath2(pluginKey);
|
|
5739
|
-
return
|
|
6141
|
+
return fs25.existsSync(manifestPath) && !!actionPlugins[pluginKey];
|
|
5740
6142
|
}
|
|
5741
6143
|
function detectPluginsToInstall(capabilities) {
|
|
5742
6144
|
const pluginKeys = /* @__PURE__ */ new Set();
|
|
@@ -5812,12 +6214,12 @@ async function installPlugins(capabilities, options) {
|
|
|
5812
6214
|
}
|
|
5813
6215
|
|
|
5814
6216
|
// src/commands/migration/versions/v001_capability/code-migrator/index.ts
|
|
5815
|
-
import
|
|
6217
|
+
import path23 from "path";
|
|
5816
6218
|
import { Project as Project3 } from "ts-morph";
|
|
5817
6219
|
|
|
5818
6220
|
// src/commands/migration/versions/v001_capability/code-migrator/scanner.ts
|
|
5819
|
-
import
|
|
5820
|
-
import
|
|
6221
|
+
import fs26 from "fs";
|
|
6222
|
+
import path22 from "path";
|
|
5821
6223
|
var EXCLUDED_DIRS = [
|
|
5822
6224
|
"node_modules",
|
|
5823
6225
|
"dist",
|
|
@@ -5832,9 +6234,9 @@ var EXCLUDED_PATTERNS = [
|
|
|
5832
6234
|
/\.d\.ts$/
|
|
5833
6235
|
];
|
|
5834
6236
|
function scanDirectory(dir, files = []) {
|
|
5835
|
-
const entries =
|
|
6237
|
+
const entries = fs26.readdirSync(dir, { withFileTypes: true });
|
|
5836
6238
|
for (const entry of entries) {
|
|
5837
|
-
const fullPath =
|
|
6239
|
+
const fullPath = path22.join(dir, entry.name);
|
|
5838
6240
|
if (entry.isDirectory()) {
|
|
5839
6241
|
if (EXCLUDED_DIRS.includes(entry.name)) {
|
|
5840
6242
|
continue;
|
|
@@ -5850,14 +6252,14 @@ function scanDirectory(dir, files = []) {
|
|
|
5850
6252
|
return files;
|
|
5851
6253
|
}
|
|
5852
6254
|
function scanServerFiles() {
|
|
5853
|
-
const serverDir =
|
|
5854
|
-
if (!
|
|
6255
|
+
const serverDir = path22.join(getProjectRoot3(), "server");
|
|
6256
|
+
if (!fs26.existsSync(serverDir)) {
|
|
5855
6257
|
return [];
|
|
5856
6258
|
}
|
|
5857
6259
|
return scanDirectory(serverDir);
|
|
5858
6260
|
}
|
|
5859
6261
|
function hasCapabilityImport(filePath) {
|
|
5860
|
-
const content =
|
|
6262
|
+
const content = fs26.readFileSync(filePath, "utf-8");
|
|
5861
6263
|
return /import\s+.*from\s+['"][^'"]*capabilities[^'"]*['"]/.test(content);
|
|
5862
6264
|
}
|
|
5863
6265
|
function scanFilesToMigrate() {
|
|
@@ -6234,7 +6636,7 @@ function analyzeFile(project, filePath, actionNameMap) {
|
|
|
6234
6636
|
const callSites = analyzeCallSites(sourceFile, imports);
|
|
6235
6637
|
const classInfo = analyzeClass(sourceFile);
|
|
6236
6638
|
const { canMigrate, reason } = canAutoMigrate(classInfo);
|
|
6237
|
-
const relativePath =
|
|
6639
|
+
const relativePath = path23.relative(getProjectRoot3(), filePath);
|
|
6238
6640
|
return {
|
|
6239
6641
|
filePath: relativePath,
|
|
6240
6642
|
imports,
|
|
@@ -6245,7 +6647,7 @@ function analyzeFile(project, filePath, actionNameMap) {
|
|
|
6245
6647
|
};
|
|
6246
6648
|
}
|
|
6247
6649
|
function migrateFile(project, analysis, dryRun) {
|
|
6248
|
-
const absolutePath =
|
|
6650
|
+
const absolutePath = path23.join(getProjectRoot3(), analysis.filePath);
|
|
6249
6651
|
if (!analysis.canAutoMigrate) {
|
|
6250
6652
|
return {
|
|
6251
6653
|
filePath: analysis.filePath,
|
|
@@ -6348,17 +6750,17 @@ function getSuggestion(analysis) {
|
|
|
6348
6750
|
}
|
|
6349
6751
|
|
|
6350
6752
|
// src/commands/migration/versions/v001_capability/cleanup.ts
|
|
6351
|
-
import
|
|
6352
|
-
import
|
|
6753
|
+
import fs27 from "fs";
|
|
6754
|
+
import path24 from "path";
|
|
6353
6755
|
function cleanupOldFiles(capabilities, dryRun) {
|
|
6354
6756
|
const deletedFiles = [];
|
|
6355
6757
|
const errors = [];
|
|
6356
6758
|
const capabilitiesDir = getCapabilitiesDir2();
|
|
6357
|
-
const oldJsonPath =
|
|
6358
|
-
if (
|
|
6759
|
+
const oldJsonPath = path24.join(capabilitiesDir, "capabilities.json");
|
|
6760
|
+
if (fs27.existsSync(oldJsonPath)) {
|
|
6359
6761
|
try {
|
|
6360
6762
|
if (!dryRun) {
|
|
6361
|
-
|
|
6763
|
+
fs27.unlinkSync(oldJsonPath);
|
|
6362
6764
|
}
|
|
6363
6765
|
deletedFiles.push("capabilities.json");
|
|
6364
6766
|
} catch (error) {
|
|
@@ -6366,11 +6768,11 @@ function cleanupOldFiles(capabilities, dryRun) {
|
|
|
6366
6768
|
}
|
|
6367
6769
|
}
|
|
6368
6770
|
for (const cap of capabilities) {
|
|
6369
|
-
const tsFilePath =
|
|
6370
|
-
if (
|
|
6771
|
+
const tsFilePath = path24.join(capabilitiesDir, `${cap.id}.ts`);
|
|
6772
|
+
if (fs27.existsSync(tsFilePath)) {
|
|
6371
6773
|
try {
|
|
6372
6774
|
if (!dryRun) {
|
|
6373
|
-
|
|
6775
|
+
fs27.unlinkSync(tsFilePath);
|
|
6374
6776
|
}
|
|
6375
6777
|
deletedFiles.push(`${cap.id}.ts`);
|
|
6376
6778
|
} catch (error) {
|
|
@@ -6386,8 +6788,8 @@ function cleanupOldFiles(capabilities, dryRun) {
|
|
|
6386
6788
|
}
|
|
6387
6789
|
|
|
6388
6790
|
// src/commands/migration/versions/v001_capability/report-generator.ts
|
|
6389
|
-
import
|
|
6390
|
-
import
|
|
6791
|
+
import fs28 from "fs";
|
|
6792
|
+
import path25 from "path";
|
|
6391
6793
|
var REPORT_FILE = "capability-migration-report.md";
|
|
6392
6794
|
function printSummary(result) {
|
|
6393
6795
|
const { jsonMigration, pluginInstallation, codeMigration, cleanup } = result;
|
|
@@ -6550,15 +6952,15 @@ async function generateReport(result) {
|
|
|
6550
6952
|
}
|
|
6551
6953
|
lines.push("");
|
|
6552
6954
|
const logDir = process.env.LOG_DIR || "logs";
|
|
6553
|
-
if (!
|
|
6955
|
+
if (!fs28.existsSync(logDir)) {
|
|
6554
6956
|
return;
|
|
6555
6957
|
}
|
|
6556
|
-
const reportDir =
|
|
6557
|
-
if (!
|
|
6558
|
-
|
|
6958
|
+
const reportDir = path25.join(logDir, "migration");
|
|
6959
|
+
if (!fs28.existsSync(reportDir)) {
|
|
6960
|
+
fs28.mkdirSync(reportDir, { recursive: true });
|
|
6559
6961
|
}
|
|
6560
|
-
const reportPath =
|
|
6561
|
-
|
|
6962
|
+
const reportPath = path25.join(reportDir, REPORT_FILE);
|
|
6963
|
+
fs28.writeFileSync(reportPath, lines.join("\n"), "utf-8");
|
|
6562
6964
|
console.log(`\u{1F4C4} Report generated: ${reportPath}`);
|
|
6563
6965
|
}
|
|
6564
6966
|
|
|
@@ -7090,10 +7492,10 @@ var migrationCommand = {
|
|
|
7090
7492
|
};
|
|
7091
7493
|
|
|
7092
7494
|
// src/commands/read-logs/index.ts
|
|
7093
|
-
import
|
|
7495
|
+
import path26 from "path";
|
|
7094
7496
|
|
|
7095
7497
|
// src/commands/read-logs/std-utils.ts
|
|
7096
|
-
import
|
|
7498
|
+
import fs29 from "fs";
|
|
7097
7499
|
function formatStdPrefixTime(localTime) {
|
|
7098
7500
|
const match = localTime.match(/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/);
|
|
7099
7501
|
if (!match) return localTime;
|
|
@@ -7123,11 +7525,11 @@ function stripPrefixFromStdLine(line) {
|
|
|
7123
7525
|
return `[${time}] ${content}`;
|
|
7124
7526
|
}
|
|
7125
7527
|
function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarker) {
|
|
7126
|
-
const stat =
|
|
7528
|
+
const stat = fs29.statSync(filePath);
|
|
7127
7529
|
if (stat.size === 0) {
|
|
7128
7530
|
return { lines: [], markerFound: false, totalLinesCount: 0 };
|
|
7129
7531
|
}
|
|
7130
|
-
const fd =
|
|
7532
|
+
const fd = fs29.openSync(filePath, "r");
|
|
7131
7533
|
const chunkSize = 64 * 1024;
|
|
7132
7534
|
let position = stat.size;
|
|
7133
7535
|
let remainder = "";
|
|
@@ -7141,7 +7543,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
|
|
|
7141
7543
|
const length = Math.min(chunkSize, position);
|
|
7142
7544
|
position -= length;
|
|
7143
7545
|
const buffer = Buffer.alloc(length);
|
|
7144
|
-
|
|
7546
|
+
fs29.readSync(fd, buffer, 0, length, position);
|
|
7145
7547
|
let chunk = buffer.toString("utf8");
|
|
7146
7548
|
if (remainder) {
|
|
7147
7549
|
chunk += remainder;
|
|
@@ -7183,7 +7585,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
|
|
|
7183
7585
|
}
|
|
7184
7586
|
}
|
|
7185
7587
|
} finally {
|
|
7186
|
-
|
|
7588
|
+
fs29.closeSync(fd);
|
|
7187
7589
|
}
|
|
7188
7590
|
return { lines: collected.reverse(), markerFound, totalLinesCount };
|
|
7189
7591
|
}
|
|
@@ -7204,21 +7606,21 @@ function readServerStdSegment(filePath, maxLines, offset) {
|
|
|
7204
7606
|
}
|
|
7205
7607
|
|
|
7206
7608
|
// src/commands/read-logs/tail.ts
|
|
7207
|
-
import
|
|
7609
|
+
import fs30 from "fs";
|
|
7208
7610
|
function fileExists(filePath) {
|
|
7209
7611
|
try {
|
|
7210
|
-
|
|
7612
|
+
fs30.accessSync(filePath, fs30.constants.F_OK | fs30.constants.R_OK);
|
|
7211
7613
|
return true;
|
|
7212
7614
|
} catch {
|
|
7213
7615
|
return false;
|
|
7214
7616
|
}
|
|
7215
7617
|
}
|
|
7216
7618
|
function readFileTailLines(filePath, maxLines) {
|
|
7217
|
-
const stat =
|
|
7619
|
+
const stat = fs30.statSync(filePath);
|
|
7218
7620
|
if (stat.size === 0) {
|
|
7219
7621
|
return [];
|
|
7220
7622
|
}
|
|
7221
|
-
const fd =
|
|
7623
|
+
const fd = fs30.openSync(filePath, "r");
|
|
7222
7624
|
const chunkSize = 64 * 1024;
|
|
7223
7625
|
const chunks = [];
|
|
7224
7626
|
let position = stat.size;
|
|
@@ -7228,13 +7630,13 @@ function readFileTailLines(filePath, maxLines) {
|
|
|
7228
7630
|
const length = Math.min(chunkSize, position);
|
|
7229
7631
|
position -= length;
|
|
7230
7632
|
const buffer = Buffer.alloc(length);
|
|
7231
|
-
|
|
7633
|
+
fs30.readSync(fd, buffer, 0, length, position);
|
|
7232
7634
|
chunks.unshift(buffer.toString("utf8"));
|
|
7233
7635
|
const chunkLines = buffer.toString("utf8").split("\n").length - 1;
|
|
7234
7636
|
collectedLines += chunkLines;
|
|
7235
7637
|
}
|
|
7236
7638
|
} finally {
|
|
7237
|
-
|
|
7639
|
+
fs30.closeSync(fd);
|
|
7238
7640
|
}
|
|
7239
7641
|
const content = chunks.join("");
|
|
7240
7642
|
const allLines = content.split("\n");
|
|
@@ -7250,11 +7652,11 @@ function readFileTailLines(filePath, maxLines) {
|
|
|
7250
7652
|
return allLines.slice(allLines.length - maxLines);
|
|
7251
7653
|
}
|
|
7252
7654
|
function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
|
|
7253
|
-
const stat =
|
|
7655
|
+
const stat = fs30.statSync(filePath);
|
|
7254
7656
|
if (stat.size === 0) {
|
|
7255
7657
|
return { lines: [], totalLinesCount: 0 };
|
|
7256
7658
|
}
|
|
7257
|
-
const fd =
|
|
7659
|
+
const fd = fs30.openSync(filePath, "r");
|
|
7258
7660
|
const chunkSize = 64 * 1024;
|
|
7259
7661
|
let position = stat.size;
|
|
7260
7662
|
let remainder = "";
|
|
@@ -7266,7 +7668,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
|
|
|
7266
7668
|
const length = Math.min(chunkSize, position);
|
|
7267
7669
|
position -= length;
|
|
7268
7670
|
const buffer = Buffer.alloc(length);
|
|
7269
|
-
|
|
7671
|
+
fs30.readSync(fd, buffer, 0, length, position);
|
|
7270
7672
|
let chunk = buffer.toString("utf8");
|
|
7271
7673
|
if (remainder) {
|
|
7272
7674
|
chunk += remainder;
|
|
@@ -7297,7 +7699,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
|
|
|
7297
7699
|
}
|
|
7298
7700
|
}
|
|
7299
7701
|
} finally {
|
|
7300
|
-
|
|
7702
|
+
fs30.closeSync(fd);
|
|
7301
7703
|
}
|
|
7302
7704
|
return { lines: collected.reverse(), totalLinesCount };
|
|
7303
7705
|
}
|
|
@@ -7439,7 +7841,7 @@ function readDevStdSegment(filePath, maxLines, offset) {
|
|
|
7439
7841
|
}
|
|
7440
7842
|
|
|
7441
7843
|
// src/commands/read-logs/json-lines.ts
|
|
7442
|
-
import
|
|
7844
|
+
import fs31 from "fs";
|
|
7443
7845
|
|
|
7444
7846
|
// src/commands/read-logs/structured-log.ts
|
|
7445
7847
|
function normalizeLevelName(value) {
|
|
@@ -7515,11 +7917,11 @@ function buildWantedLevelSet(levels) {
|
|
|
7515
7917
|
return set.size > 0 ? set : null;
|
|
7516
7918
|
}
|
|
7517
7919
|
function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
|
|
7518
|
-
const stat =
|
|
7920
|
+
const stat = fs31.statSync(filePath);
|
|
7519
7921
|
if (stat.size === 0) {
|
|
7520
7922
|
return { lines: [], totalLinesCount: 0 };
|
|
7521
7923
|
}
|
|
7522
|
-
const fd =
|
|
7924
|
+
const fd = fs31.openSync(filePath, "r");
|
|
7523
7925
|
const chunkSize = 64 * 1024;
|
|
7524
7926
|
let position = stat.size;
|
|
7525
7927
|
let remainder = "";
|
|
@@ -7534,7 +7936,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
|
|
|
7534
7936
|
const length = Math.min(chunkSize, position);
|
|
7535
7937
|
position -= length;
|
|
7536
7938
|
const buffer = Buffer.alloc(length);
|
|
7537
|
-
|
|
7939
|
+
fs31.readSync(fd, buffer, 0, length, position);
|
|
7538
7940
|
let chunk = buffer.toString("utf8");
|
|
7539
7941
|
if (remainder) {
|
|
7540
7942
|
chunk += remainder;
|
|
@@ -7596,7 +7998,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
|
|
|
7596
7998
|
}
|
|
7597
7999
|
}
|
|
7598
8000
|
} finally {
|
|
7599
|
-
|
|
8001
|
+
fs31.closeSync(fd);
|
|
7600
8002
|
}
|
|
7601
8003
|
return { lines: collected.reverse(), totalLinesCount };
|
|
7602
8004
|
}
|
|
@@ -7639,11 +8041,11 @@ function extractTraceId(obj) {
|
|
|
7639
8041
|
function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
|
|
7640
8042
|
const wanted = traceId.trim();
|
|
7641
8043
|
if (!wanted) return { lines: [], totalLinesCount: 0 };
|
|
7642
|
-
const stat =
|
|
8044
|
+
const stat = fs31.statSync(filePath);
|
|
7643
8045
|
if (stat.size === 0) {
|
|
7644
8046
|
return { lines: [], totalLinesCount: 0 };
|
|
7645
8047
|
}
|
|
7646
|
-
const fd =
|
|
8048
|
+
const fd = fs31.openSync(filePath, "r");
|
|
7647
8049
|
const chunkSize = 64 * 1024;
|
|
7648
8050
|
let position = stat.size;
|
|
7649
8051
|
let remainder = "";
|
|
@@ -7656,7 +8058,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
|
|
|
7656
8058
|
const length = Math.min(chunkSize, position);
|
|
7657
8059
|
position -= length;
|
|
7658
8060
|
const buffer = Buffer.alloc(length);
|
|
7659
|
-
|
|
8061
|
+
fs31.readSync(fd, buffer, 0, length, position);
|
|
7660
8062
|
let chunk = buffer.toString("utf8");
|
|
7661
8063
|
if (remainder) {
|
|
7662
8064
|
chunk += remainder;
|
|
@@ -7709,7 +8111,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
|
|
|
7709
8111
|
}
|
|
7710
8112
|
}
|
|
7711
8113
|
} finally {
|
|
7712
|
-
|
|
8114
|
+
fs31.closeSync(fd);
|
|
7713
8115
|
}
|
|
7714
8116
|
return { lines: collected.reverse(), totalLinesCount };
|
|
7715
8117
|
}
|
|
@@ -7718,11 +8120,11 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
|
|
|
7718
8120
|
if (!wantedLevelSet) {
|
|
7719
8121
|
return { lines: [], totalLinesCount: 0 };
|
|
7720
8122
|
}
|
|
7721
|
-
const stat =
|
|
8123
|
+
const stat = fs31.statSync(filePath);
|
|
7722
8124
|
if (stat.size === 0) {
|
|
7723
8125
|
return { lines: [], totalLinesCount: 0 };
|
|
7724
8126
|
}
|
|
7725
|
-
const fd =
|
|
8127
|
+
const fd = fs31.openSync(filePath, "r");
|
|
7726
8128
|
const chunkSize = 64 * 1024;
|
|
7727
8129
|
let position = stat.size;
|
|
7728
8130
|
let remainder = "";
|
|
@@ -7734,7 +8136,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
|
|
|
7734
8136
|
const length = Math.min(chunkSize, position);
|
|
7735
8137
|
position -= length;
|
|
7736
8138
|
const buffer = Buffer.alloc(length);
|
|
7737
|
-
|
|
8139
|
+
fs31.readSync(fd, buffer, 0, length, position);
|
|
7738
8140
|
let chunk = buffer.toString("utf8");
|
|
7739
8141
|
if (remainder) {
|
|
7740
8142
|
chunk += remainder;
|
|
@@ -7781,7 +8183,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
|
|
|
7781
8183
|
}
|
|
7782
8184
|
}
|
|
7783
8185
|
} finally {
|
|
7784
|
-
|
|
8186
|
+
fs31.closeSync(fd);
|
|
7785
8187
|
}
|
|
7786
8188
|
return { lines: collected.reverse(), totalLinesCount };
|
|
7787
8189
|
}
|
|
@@ -8274,30 +8676,30 @@ async function readLogsJsonResult(options) {
|
|
|
8274
8676
|
};
|
|
8275
8677
|
}
|
|
8276
8678
|
function resolveLogFilePath(logDir, type) {
|
|
8277
|
-
const base =
|
|
8679
|
+
const base = path26.isAbsolute(logDir) ? logDir : path26.join(process.cwd(), logDir);
|
|
8278
8680
|
if (type === "server") {
|
|
8279
|
-
return
|
|
8681
|
+
return path26.join(base, "server.log");
|
|
8280
8682
|
}
|
|
8281
8683
|
if (type === "trace") {
|
|
8282
|
-
return
|
|
8684
|
+
return path26.join(base, "trace.log");
|
|
8283
8685
|
}
|
|
8284
8686
|
if (type === "server-std") {
|
|
8285
|
-
return
|
|
8687
|
+
return path26.join(base, "server.std.log");
|
|
8286
8688
|
}
|
|
8287
8689
|
if (type === "client-std") {
|
|
8288
|
-
return
|
|
8690
|
+
return path26.join(base, "client.std.log");
|
|
8289
8691
|
}
|
|
8290
8692
|
if (type === "dev") {
|
|
8291
|
-
return
|
|
8693
|
+
return path26.join(base, "dev.log");
|
|
8292
8694
|
}
|
|
8293
8695
|
if (type === "dev-std") {
|
|
8294
|
-
return
|
|
8696
|
+
return path26.join(base, "dev.std.log");
|
|
8295
8697
|
}
|
|
8296
8698
|
if (type === "install-dep-std") {
|
|
8297
|
-
return
|
|
8699
|
+
return path26.join(base, "install-dep.std.log");
|
|
8298
8700
|
}
|
|
8299
8701
|
if (type === "browser") {
|
|
8300
|
-
return
|
|
8702
|
+
return path26.join(base, "browser.log");
|
|
8301
8703
|
}
|
|
8302
8704
|
throw new Error(`Unsupported log type: ${type}`);
|
|
8303
8705
|
}
|
|
@@ -8467,9 +8869,9 @@ function camelToKebab(str) {
|
|
|
8467
8869
|
}
|
|
8468
8870
|
|
|
8469
8871
|
// src/commands/build/upload-static.handler.ts
|
|
8470
|
-
import * as
|
|
8872
|
+
import * as fs32 from "fs";
|
|
8471
8873
|
import * as os2 from "os";
|
|
8472
|
-
import * as
|
|
8874
|
+
import * as path27 from "path";
|
|
8473
8875
|
import { execFileSync } from "child_process";
|
|
8474
8876
|
function readCredentialsFromEnv() {
|
|
8475
8877
|
const uploadPrefix = process.env.STATIC_UPLOAD_PREFIX;
|
|
@@ -8493,8 +8895,8 @@ async function uploadStatic(options) {
|
|
|
8493
8895
|
endpoint = UPLOAD_STATIC_DEFAULTS.endpoint,
|
|
8494
8896
|
region = UPLOAD_STATIC_DEFAULTS.region
|
|
8495
8897
|
} = options;
|
|
8496
|
-
const resolvedStaticDir =
|
|
8497
|
-
if (!
|
|
8898
|
+
const resolvedStaticDir = path27.resolve(staticDir);
|
|
8899
|
+
if (!fs32.existsSync(resolvedStaticDir)) {
|
|
8498
8900
|
console.error(`${LOG_PREFIX} \u76EE\u5F55\u4E0D\u5B58\u5728: ${resolvedStaticDir}\uFF0C\u8DF3\u8FC7\u4E0A\u4F20`);
|
|
8499
8901
|
return;
|
|
8500
8902
|
}
|
|
@@ -8527,8 +8929,8 @@ async function uploadStatic(options) {
|
|
|
8527
8929
|
({ AccessKeyID: accessKeyID, SecretAccessKey: secretAccessKey, SessionToken: sessionToken } = uploadCredential);
|
|
8528
8930
|
}
|
|
8529
8931
|
console.error(`${LOG_PREFIX} \u4E0A\u4F20\u76EE\u6807: ${uploadPrefix}`);
|
|
8530
|
-
const confPath =
|
|
8531
|
-
|
|
8932
|
+
const confPath = path27.join(os2.tmpdir(), `.tosutilconfig-static-${process.pid}`);
|
|
8933
|
+
fs32.writeFileSync(confPath, "");
|
|
8532
8934
|
try {
|
|
8533
8935
|
console.error(`${LOG_PREFIX} \u914D\u7F6E tosutil...`);
|
|
8534
8936
|
configureTosutil(resolvedTosutil, confPath, {
|
|
@@ -8542,7 +8944,7 @@ async function uploadStatic(options) {
|
|
|
8542
8944
|
uploadToTos(resolvedTosutil, confPath, resolvedStaticDir, uploadPrefix);
|
|
8543
8945
|
} finally {
|
|
8544
8946
|
try {
|
|
8545
|
-
|
|
8947
|
+
fs32.unlinkSync(confPath);
|
|
8546
8948
|
} catch {
|
|
8547
8949
|
}
|
|
8548
8950
|
}
|
|
@@ -8562,8 +8964,8 @@ async function uploadStatic(options) {
|
|
|
8562
8964
|
}
|
|
8563
8965
|
}
|
|
8564
8966
|
function resolveTosutilPath(tosutilPath) {
|
|
8565
|
-
if (
|
|
8566
|
-
return
|
|
8967
|
+
if (path27.isAbsolute(tosutilPath)) {
|
|
8968
|
+
return fs32.existsSync(tosutilPath) ? tosutilPath : null;
|
|
8567
8969
|
}
|
|
8568
8970
|
try {
|
|
8569
8971
|
const resolved = execFileSync("which", [tosutilPath], { encoding: "utf-8" }).trim();
|
|
@@ -8608,7 +9010,7 @@ async function resolveBucketId(appId) {
|
|
|
8608
9010
|
return bucketId;
|
|
8609
9011
|
}
|
|
8610
9012
|
function isDirEmpty(dirPath) {
|
|
8611
|
-
const entries =
|
|
9013
|
+
const entries = fs32.readdirSync(dirPath);
|
|
8612
9014
|
return entries.length === 0;
|
|
8613
9015
|
}
|
|
8614
9016
|
|
|
@@ -8704,13 +9106,13 @@ var commands = [
|
|
|
8704
9106
|
|
|
8705
9107
|
// src/index.ts
|
|
8706
9108
|
for (const filename of [".env.local", ".env"]) {
|
|
8707
|
-
const envPath =
|
|
8708
|
-
if (
|
|
9109
|
+
const envPath = path28.join(process.cwd(), filename);
|
|
9110
|
+
if (fs33.existsSync(envPath)) {
|
|
8709
9111
|
dotenvConfig({ path: envPath });
|
|
8710
9112
|
}
|
|
8711
9113
|
}
|
|
8712
|
-
var __dirname =
|
|
8713
|
-
var pkg = JSON.parse(
|
|
9114
|
+
var __dirname = path28.dirname(fileURLToPath5(import.meta.url));
|
|
9115
|
+
var pkg = JSON.parse(fs33.readFileSync(path28.join(__dirname, "../package.json"), "utf-8"));
|
|
8714
9116
|
var cli = new FullstackCLI(pkg.version);
|
|
8715
9117
|
cli.useAll(commands);
|
|
8716
9118
|
cli.run();
|