@walkeros/cli 0.5.1-next.1 → 0.7.0-next.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/CHANGELOG.md +12 -0
- package/dist/__tests__/core/docker-url.test.d.ts +2 -0
- package/dist/__tests__/core/docker-url.test.d.ts.map +1 -0
- package/dist/__tests__/core/docker-url.test.js +54 -0
- package/dist/__tests__/core/docker-url.test.js.map +1 -0
- package/dist/core/docker.d.ts +4 -1
- package/dist/core/docker.d.ts.map +1 -1
- package/dist/core/docker.js +49 -24
- package/dist/core/docker.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +125 -96
- package/dist/index.js.map +1 -1
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +27 -0
- package/dist/version.js.map +1 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2,10 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import { Command } from "commander";
|
|
5
|
+
import { VERSION as DOCKER_VERSION2 } from "@walkeros/docker";
|
|
6
|
+
|
|
7
|
+
// src/version.ts
|
|
5
8
|
import { readFileSync } from "fs";
|
|
6
|
-
import { fileURLToPath
|
|
9
|
+
import { fileURLToPath } from "url";
|
|
7
10
|
import { dirname, join } from "path";
|
|
8
|
-
|
|
11
|
+
var versionFilename = fileURLToPath(import.meta.url);
|
|
12
|
+
var versionDirname = dirname(versionFilename);
|
|
13
|
+
function findPackageJson() {
|
|
14
|
+
const paths = [
|
|
15
|
+
join(versionDirname, "../package.json"),
|
|
16
|
+
// dist/ or src/
|
|
17
|
+
join(versionDirname, "../../package.json")
|
|
18
|
+
// src/core/ (not used, but safe)
|
|
19
|
+
];
|
|
20
|
+
for (const p of paths) {
|
|
21
|
+
try {
|
|
22
|
+
return readFileSync(p, "utf-8");
|
|
23
|
+
} catch {
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return JSON.stringify({ version: "0.0.0" });
|
|
27
|
+
}
|
|
28
|
+
var VERSION = JSON.parse(findPackageJson()).version;
|
|
9
29
|
|
|
10
30
|
// src/commands/bundle/index.ts
|
|
11
31
|
import path9 from "path";
|
|
@@ -135,6 +155,7 @@ function formatBytes(bytes) {
|
|
|
135
155
|
// src/core/docker.ts
|
|
136
156
|
import { spawn } from "child_process";
|
|
137
157
|
import path2 from "path";
|
|
158
|
+
import fs2 from "fs-extra";
|
|
138
159
|
import { VERSION as DOCKER_VERSION } from "@walkeros/docker";
|
|
139
160
|
|
|
140
161
|
// src/config/utils.ts
|
|
@@ -264,8 +285,7 @@ async function loadJsonFromSource(source, options) {
|
|
|
264
285
|
}
|
|
265
286
|
|
|
266
287
|
// src/core/docker.ts
|
|
267
|
-
var
|
|
268
|
-
var CLI_DOCKER_IMAGE = process.env.WALKEROS_CLI_DOCKER_IMAGE || `walkeros/cli:${CLI_VERSION}`;
|
|
288
|
+
var CLI_DOCKER_IMAGE = process.env.WALKEROS_CLI_DOCKER_IMAGE || `walkeros/cli:${VERSION}`;
|
|
269
289
|
var RUNTIME_DOCKER_IMAGE = process.env.WALKEROS_RUNTIME_DOCKER_IMAGE || `walkeros/docker:${DOCKER_VERSION}`;
|
|
270
290
|
function buildCommonDockerArgs(options) {
|
|
271
291
|
const args = [options.config];
|
|
@@ -305,29 +325,44 @@ function buildDockerCommand(command, args, options = {}, configFile) {
|
|
|
305
325
|
return cmd;
|
|
306
326
|
}
|
|
307
327
|
async function executeInDocker(command, args, options = {}, configFile) {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
328
|
+
let tempFile;
|
|
329
|
+
let effectiveConfigFile = configFile;
|
|
330
|
+
try {
|
|
331
|
+
if (configFile && isUrl(configFile)) {
|
|
332
|
+
tempFile = await downloadFromUrl(configFile);
|
|
333
|
+
effectiveConfigFile = tempFile;
|
|
334
|
+
}
|
|
335
|
+
const containerArgs = [...args, "--local"];
|
|
336
|
+
const dockerCmd = buildDockerCommand(
|
|
337
|
+
command,
|
|
338
|
+
containerArgs,
|
|
339
|
+
options,
|
|
340
|
+
effectiveConfigFile
|
|
341
|
+
);
|
|
342
|
+
return await new Promise((resolve, reject) => {
|
|
343
|
+
const proc = spawn(dockerCmd[0], dockerCmd.slice(1), {
|
|
344
|
+
stdio: options.silent ? "ignore" : "inherit",
|
|
345
|
+
shell: false
|
|
346
|
+
});
|
|
347
|
+
proc.on("error", (error) => {
|
|
348
|
+
reject(new Error(`Docker execution failed: ${error.message}`));
|
|
349
|
+
});
|
|
350
|
+
proc.on("exit", (code) => {
|
|
351
|
+
if (code === 0) {
|
|
352
|
+
resolve();
|
|
353
|
+
} else {
|
|
354
|
+
process.exit(code || 1);
|
|
355
|
+
}
|
|
356
|
+
});
|
|
322
357
|
});
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
358
|
+
} finally {
|
|
359
|
+
if (tempFile) {
|
|
360
|
+
try {
|
|
361
|
+
await fs2.remove(tempFile);
|
|
362
|
+
} catch {
|
|
328
363
|
}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
331
366
|
}
|
|
332
367
|
async function isDockerAvailable() {
|
|
333
368
|
return new Promise((resolve) => {
|
|
@@ -440,16 +475,16 @@ async function executeCommand(localHandler, dockerCommand, dockerArgs, options,
|
|
|
440
475
|
|
|
441
476
|
// src/core/temp-manager.ts
|
|
442
477
|
import { getHashServer } from "@walkeros/server-core";
|
|
443
|
-
import
|
|
478
|
+
import fs3 from "fs-extra";
|
|
444
479
|
|
|
445
480
|
// src/core/asset-resolver.ts
|
|
446
|
-
import { fileURLToPath } from "url";
|
|
481
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
447
482
|
import { existsSync } from "fs";
|
|
448
483
|
import path3 from "path";
|
|
449
484
|
var cachedAssetDir;
|
|
450
485
|
function getAssetDir() {
|
|
451
486
|
if (cachedAssetDir) return cachedAssetDir;
|
|
452
|
-
const currentFile =
|
|
487
|
+
const currentFile = fileURLToPath2(import.meta.url);
|
|
453
488
|
let dir = path3.dirname(currentFile);
|
|
454
489
|
while (dir !== path3.dirname(dir)) {
|
|
455
490
|
if (existsSync(path3.join(dir, "examples"))) {
|
|
@@ -482,22 +517,22 @@ function getErrorMessage(error) {
|
|
|
482
517
|
|
|
483
518
|
// src/core/local-packages.ts
|
|
484
519
|
import path4 from "path";
|
|
485
|
-
import
|
|
520
|
+
import fs4 from "fs-extra";
|
|
486
521
|
async function resolveLocalPackage(packageName, localPath, configDir, logger2) {
|
|
487
522
|
const absolutePath = path4.isAbsolute(localPath) ? localPath : path4.resolve(configDir, localPath);
|
|
488
|
-
if (!await
|
|
523
|
+
if (!await fs4.pathExists(absolutePath)) {
|
|
489
524
|
throw new Error(
|
|
490
525
|
`Local package path not found: ${localPath} (resolved to ${absolutePath})`
|
|
491
526
|
);
|
|
492
527
|
}
|
|
493
528
|
const pkgJsonPath = path4.join(absolutePath, "package.json");
|
|
494
|
-
if (!await
|
|
529
|
+
if (!await fs4.pathExists(pkgJsonPath)) {
|
|
495
530
|
throw new Error(
|
|
496
531
|
`No package.json found at ${absolutePath}. Is this a valid package directory?`
|
|
497
532
|
);
|
|
498
533
|
}
|
|
499
534
|
const distPath = path4.join(absolutePath, "dist");
|
|
500
|
-
const hasDistFolder = await
|
|
535
|
+
const hasDistFolder = await fs4.pathExists(distPath);
|
|
501
536
|
if (!hasDistFolder) {
|
|
502
537
|
logger2.warn(
|
|
503
538
|
`\u26A0\uFE0F ${packageName}: No dist/ folder found. Using package root.`
|
|
@@ -512,18 +547,18 @@ async function resolveLocalPackage(packageName, localPath, configDir, logger2) {
|
|
|
512
547
|
}
|
|
513
548
|
async function copyLocalPackage(localPkg, targetDir, logger2) {
|
|
514
549
|
const packageDir = path4.join(targetDir, "node_modules", localPkg.name);
|
|
515
|
-
await
|
|
516
|
-
await
|
|
550
|
+
await fs4.ensureDir(path4.dirname(packageDir));
|
|
551
|
+
await fs4.copy(
|
|
517
552
|
path4.join(localPkg.absolutePath, "package.json"),
|
|
518
553
|
path4.join(packageDir, "package.json")
|
|
519
554
|
);
|
|
520
555
|
if (localPkg.hasDistFolder) {
|
|
521
|
-
await
|
|
556
|
+
await fs4.copy(localPkg.distPath, path4.join(packageDir, "dist"));
|
|
522
557
|
} else {
|
|
523
|
-
const entries = await
|
|
558
|
+
const entries = await fs4.readdir(localPkg.absolutePath);
|
|
524
559
|
for (const entry of entries) {
|
|
525
560
|
if (!["node_modules", ".turbo", ".git"].includes(entry)) {
|
|
526
|
-
await
|
|
561
|
+
await fs4.copy(
|
|
527
562
|
path4.join(localPkg.absolutePath, entry),
|
|
528
563
|
path4.join(packageDir, entry)
|
|
529
564
|
);
|
|
@@ -590,7 +625,7 @@ function getDefaultOutput(platform) {
|
|
|
590
625
|
|
|
591
626
|
// src/config/loader.ts
|
|
592
627
|
import path5 from "path";
|
|
593
|
-
import
|
|
628
|
+
import fs5 from "fs-extra";
|
|
594
629
|
import { getFlowConfig, getPlatform } from "@walkeros/core";
|
|
595
630
|
var DEFAULT_INCLUDE_FOLDER = "./shared";
|
|
596
631
|
function loadBundleConfig(rawConfig, options) {
|
|
@@ -617,7 +652,7 @@ function loadBundleConfig(rawConfig, options) {
|
|
|
617
652
|
let includes = setup.include;
|
|
618
653
|
if (!includes) {
|
|
619
654
|
const defaultIncludePath = path5.resolve(configDir, DEFAULT_INCLUDE_FOLDER);
|
|
620
|
-
if (
|
|
655
|
+
if (fs5.pathExistsSync(defaultIncludePath)) {
|
|
621
656
|
includes = [DEFAULT_INCLUDE_FOLDER];
|
|
622
657
|
}
|
|
623
658
|
}
|
|
@@ -680,13 +715,13 @@ function loadAllFlows(rawConfig, options) {
|
|
|
680
715
|
// src/commands/bundle/bundler.ts
|
|
681
716
|
import esbuild from "esbuild";
|
|
682
717
|
import path8 from "path";
|
|
683
|
-
import
|
|
718
|
+
import fs8 from "fs-extra";
|
|
684
719
|
import { packageNameToVariable } from "@walkeros/core";
|
|
685
720
|
|
|
686
721
|
// src/commands/bundle/package-manager.ts
|
|
687
722
|
import pacote from "pacote";
|
|
688
723
|
import path6 from "path";
|
|
689
|
-
import
|
|
724
|
+
import fs6 from "fs-extra";
|
|
690
725
|
|
|
691
726
|
// src/core/cache-utils.ts
|
|
692
727
|
import { getHashServer as getHashServer2 } from "@walkeros/server-core";
|
|
@@ -729,7 +764,7 @@ async function getCachedPackagePath(pkg, tempDir) {
|
|
|
729
764
|
}
|
|
730
765
|
async function isPackageCached(pkg, tempDir) {
|
|
731
766
|
const cachedPath = await getCachedPackagePath(pkg, tempDir);
|
|
732
|
-
return
|
|
767
|
+
return fs6.pathExists(cachedPath);
|
|
733
768
|
}
|
|
734
769
|
function validateNoDuplicatePackages(packages) {
|
|
735
770
|
const packageMap = /* @__PURE__ */ new Map();
|
|
@@ -764,11 +799,11 @@ async function resolveDependencies(pkg, packageDir, logger2, visited = /* @__PUR
|
|
|
764
799
|
visited.add(pkgKey);
|
|
765
800
|
try {
|
|
766
801
|
const packageJsonPath = path6.join(packageDir, "package.json");
|
|
767
|
-
if (await
|
|
768
|
-
const
|
|
802
|
+
if (await fs6.pathExists(packageJsonPath)) {
|
|
803
|
+
const packageJson = await fs6.readJson(packageJsonPath);
|
|
769
804
|
const deps = {
|
|
770
|
-
...
|
|
771
|
-
...
|
|
805
|
+
...packageJson.dependencies,
|
|
806
|
+
...packageJson.peerDependencies
|
|
772
807
|
};
|
|
773
808
|
for (const [name, versionSpec] of Object.entries(deps)) {
|
|
774
809
|
if (typeof versionSpec === "string") {
|
|
@@ -792,7 +827,7 @@ async function downloadPackages(packages, targetDir, logger2, useCache = true, c
|
|
|
792
827
|
}
|
|
793
828
|
}
|
|
794
829
|
validateNoDuplicatePackages(packages);
|
|
795
|
-
await
|
|
830
|
+
await fs6.ensureDir(targetDir);
|
|
796
831
|
while (downloadQueue.length > 0) {
|
|
797
832
|
const pkg = downloadQueue.shift();
|
|
798
833
|
const pkgKey = `${pkg.name}@${pkg.version}`;
|
|
@@ -827,8 +862,8 @@ async function downloadPackages(packages, targetDir, logger2, useCache = true, c
|
|
|
827
862
|
if (useCache && await isPackageCached(pkg, targetDir)) {
|
|
828
863
|
logger2.debug(`Using cached ${packageSpec}...`);
|
|
829
864
|
try {
|
|
830
|
-
await
|
|
831
|
-
await
|
|
865
|
+
await fs6.ensureDir(path6.dirname(packageDir));
|
|
866
|
+
await fs6.copy(cachedPath, packageDir);
|
|
832
867
|
packagePaths.set(pkg.name, packageDir);
|
|
833
868
|
const deps = await resolveDependencies(pkg, packageDir, logger2);
|
|
834
869
|
for (const dep of deps) {
|
|
@@ -846,7 +881,7 @@ async function downloadPackages(packages, targetDir, logger2, useCache = true, c
|
|
|
846
881
|
}
|
|
847
882
|
logger2.debug(`Downloading ${packageSpec}...`);
|
|
848
883
|
try {
|
|
849
|
-
await
|
|
884
|
+
await fs6.ensureDir(path6.dirname(packageDir));
|
|
850
885
|
const cacheDir = process.env.NPM_CACHE_DIR || path6.join(process.cwd(), ".npm-cache");
|
|
851
886
|
await pacote.extract(packageSpec, packageDir, {
|
|
852
887
|
// Force npm registry download, prevent workspace resolution
|
|
@@ -860,8 +895,8 @@ async function downloadPackages(packages, targetDir, logger2, useCache = true, c
|
|
|
860
895
|
});
|
|
861
896
|
if (useCache) {
|
|
862
897
|
try {
|
|
863
|
-
await
|
|
864
|
-
await
|
|
898
|
+
await fs6.ensureDir(path6.dirname(cachedPath));
|
|
899
|
+
await fs6.copy(packageDir, cachedPath);
|
|
865
900
|
logger2.debug(`Cached ${packageSpec} for future use`);
|
|
866
901
|
} catch (cacheError) {
|
|
867
902
|
logger2.debug(`Failed to cache ${packageSpec}: ${cacheError}`);
|
|
@@ -883,7 +918,7 @@ async function downloadPackages(packages, targetDir, logger2, useCache = true, c
|
|
|
883
918
|
}
|
|
884
919
|
|
|
885
920
|
// src/core/build-cache.ts
|
|
886
|
-
import
|
|
921
|
+
import fs7 from "fs-extra";
|
|
887
922
|
import path7 from "path";
|
|
888
923
|
var BUILD_CACHE_DIR = path7.join(".tmp", "cache", "builds");
|
|
889
924
|
async function getBuildCachePath(configContent, cacheDir = BUILD_CACHE_DIR) {
|
|
@@ -892,17 +927,17 @@ async function getBuildCachePath(configContent, cacheDir = BUILD_CACHE_DIR) {
|
|
|
892
927
|
}
|
|
893
928
|
async function isBuildCached(configContent, cacheDir = BUILD_CACHE_DIR) {
|
|
894
929
|
const cachePath = await getBuildCachePath(configContent, cacheDir);
|
|
895
|
-
return
|
|
930
|
+
return fs7.pathExists(cachePath);
|
|
896
931
|
}
|
|
897
932
|
async function cacheBuild(configContent, buildOutput, cacheDir = BUILD_CACHE_DIR) {
|
|
898
933
|
const cachePath = await getBuildCachePath(configContent, cacheDir);
|
|
899
|
-
await
|
|
900
|
-
await
|
|
934
|
+
await fs7.ensureDir(path7.dirname(cachePath));
|
|
935
|
+
await fs7.writeFile(cachePath, buildOutput, "utf-8");
|
|
901
936
|
}
|
|
902
937
|
async function getCachedBuild(configContent, cacheDir = BUILD_CACHE_DIR) {
|
|
903
938
|
const cachePath = await getBuildCachePath(configContent, cacheDir);
|
|
904
|
-
if (await
|
|
905
|
-
return await
|
|
939
|
+
if (await fs7.pathExists(cachePath)) {
|
|
940
|
+
return await fs7.readFile(cachePath, "utf-8");
|
|
906
941
|
}
|
|
907
942
|
return null;
|
|
908
943
|
}
|
|
@@ -913,8 +948,8 @@ async function copyIncludes(includes, sourceDir, outputDir, logger2) {
|
|
|
913
948
|
const sourcePath = path8.resolve(sourceDir, include);
|
|
914
949
|
const folderName = path8.basename(include);
|
|
915
950
|
const destPath = path8.join(outputDir, folderName);
|
|
916
|
-
if (await
|
|
917
|
-
await
|
|
951
|
+
if (await fs8.pathExists(sourcePath)) {
|
|
952
|
+
await fs8.copy(sourcePath, destPath);
|
|
918
953
|
logger2.debug(`Copied ${include} to output`);
|
|
919
954
|
} else {
|
|
920
955
|
logger2.debug(`Include folder not found: ${include}`);
|
|
@@ -944,12 +979,12 @@ async function bundleCore(flowConfig, buildOptions, logger2, showStats = false)
|
|
|
944
979
|
if (cachedBuild) {
|
|
945
980
|
logger2.info("\u2728 Using cached build");
|
|
946
981
|
const outputPath = path8.resolve(buildOptions.output);
|
|
947
|
-
await
|
|
948
|
-
await
|
|
982
|
+
await fs8.ensureDir(path8.dirname(outputPath));
|
|
983
|
+
await fs8.writeFile(outputPath, cachedBuild);
|
|
949
984
|
logger2.gray(`Output: ${outputPath}`);
|
|
950
985
|
logger2.success("\u2705 Build completed (from cache)");
|
|
951
986
|
if (showStats) {
|
|
952
|
-
const stats = await
|
|
987
|
+
const stats = await fs8.stat(outputPath);
|
|
953
988
|
const packageStats = Object.entries(buildOptions.packages).map(
|
|
954
989
|
([name, pkg]) => ({
|
|
955
990
|
name: `${name}@${pkg.version || "latest"}`,
|
|
@@ -970,7 +1005,7 @@ async function bundleCore(flowConfig, buildOptions, logger2, showStats = false)
|
|
|
970
1005
|
}
|
|
971
1006
|
try {
|
|
972
1007
|
if (!buildOptions.tempDir) {
|
|
973
|
-
await
|
|
1008
|
+
await fs8.emptyDir(TEMP_DIR);
|
|
974
1009
|
}
|
|
975
1010
|
logger2.debug("Cleaned temporary directory");
|
|
976
1011
|
logger2.info("\u{1F4E5} Downloading packages...");
|
|
@@ -993,7 +1028,7 @@ async function bundleCore(flowConfig, buildOptions, logger2, showStats = false)
|
|
|
993
1028
|
for (const [pkgName, pkgPath] of packagePaths.entries()) {
|
|
994
1029
|
if (pkgName.startsWith("@walkeros/")) {
|
|
995
1030
|
const pkgJsonPath = path8.join(pkgPath, "package.json");
|
|
996
|
-
const pkgJson = await
|
|
1031
|
+
const pkgJson = await fs8.readJSON(pkgJsonPath);
|
|
997
1032
|
if (!pkgJson.exports && pkgJson.module) {
|
|
998
1033
|
pkgJson.exports = {
|
|
999
1034
|
".": {
|
|
@@ -1001,12 +1036,12 @@ async function bundleCore(flowConfig, buildOptions, logger2, showStats = false)
|
|
|
1001
1036
|
require: pkgJson.main
|
|
1002
1037
|
}
|
|
1003
1038
|
};
|
|
1004
|
-
await
|
|
1039
|
+
await fs8.writeJSON(pkgJsonPath, pkgJson, { spaces: 2 });
|
|
1005
1040
|
}
|
|
1006
1041
|
}
|
|
1007
1042
|
}
|
|
1008
1043
|
const packageJsonPath = path8.join(TEMP_DIR, "package.json");
|
|
1009
|
-
await
|
|
1044
|
+
await fs8.writeFile(
|
|
1010
1045
|
packageJsonPath,
|
|
1011
1046
|
JSON.stringify({ type: "module" }, null, 2)
|
|
1012
1047
|
);
|
|
@@ -1017,10 +1052,10 @@ async function bundleCore(flowConfig, buildOptions, logger2, showStats = false)
|
|
|
1017
1052
|
packagePaths
|
|
1018
1053
|
);
|
|
1019
1054
|
const entryPath = path8.join(TEMP_DIR, "entry.js");
|
|
1020
|
-
await
|
|
1055
|
+
await fs8.writeFile(entryPath, entryContent);
|
|
1021
1056
|
logger2.info("\u26A1 Bundling with esbuild...");
|
|
1022
1057
|
const outputPath = path8.resolve(buildOptions.output);
|
|
1023
|
-
await
|
|
1058
|
+
await fs8.ensureDir(path8.dirname(outputPath));
|
|
1024
1059
|
const esbuildOptions = createEsbuildOptions(
|
|
1025
1060
|
buildOptions,
|
|
1026
1061
|
entryPath,
|
|
@@ -1040,7 +1075,7 @@ async function bundleCore(flowConfig, buildOptions, logger2, showStats = false)
|
|
|
1040
1075
|
logger2.gray(`Output: ${outputPath}`);
|
|
1041
1076
|
if (buildOptions.cache !== false) {
|
|
1042
1077
|
const configContent = generateCacheKeyContent(flowConfig, buildOptions);
|
|
1043
|
-
const buildOutput = await
|
|
1078
|
+
const buildOutput = await fs8.readFile(outputPath, "utf-8");
|
|
1044
1079
|
await cacheBuild(configContent, buildOutput);
|
|
1045
1080
|
logger2.debug("Build cached for future use");
|
|
1046
1081
|
}
|
|
@@ -1063,20 +1098,20 @@ async function bundleCore(flowConfig, buildOptions, logger2, showStats = false)
|
|
|
1063
1098
|
);
|
|
1064
1099
|
}
|
|
1065
1100
|
if (!buildOptions.tempDir) {
|
|
1066
|
-
await
|
|
1101
|
+
await fs8.remove(TEMP_DIR);
|
|
1067
1102
|
logger2.debug("Cleaned up temporary files");
|
|
1068
1103
|
}
|
|
1069
1104
|
return stats;
|
|
1070
1105
|
} catch (error) {
|
|
1071
1106
|
if (!buildOptions.tempDir) {
|
|
1072
|
-
await
|
|
1107
|
+
await fs8.remove(TEMP_DIR).catch(() => {
|
|
1073
1108
|
});
|
|
1074
1109
|
}
|
|
1075
1110
|
throw error;
|
|
1076
1111
|
}
|
|
1077
1112
|
}
|
|
1078
1113
|
async function collectBundleStats(outputPath, packages, startTime, entryContent) {
|
|
1079
|
-
const stats = await
|
|
1114
|
+
const stats = await fs8.stat(outputPath);
|
|
1080
1115
|
const totalSize = stats.size;
|
|
1081
1116
|
const buildTime = Date.now() - startTime;
|
|
1082
1117
|
const packageStats = Object.entries(packages).map(([name, pkg]) => {
|
|
@@ -1590,7 +1625,7 @@ async function bundle(configOrPath, options = {}) {
|
|
|
1590
1625
|
|
|
1591
1626
|
// src/commands/simulate/simulator.ts
|
|
1592
1627
|
import path10 from "path";
|
|
1593
|
-
import
|
|
1628
|
+
import fs10 from "fs-extra";
|
|
1594
1629
|
import { getPlatform as getPlatform2 } from "@walkeros/core";
|
|
1595
1630
|
|
|
1596
1631
|
// src/commands/simulate/tracker.ts
|
|
@@ -1673,7 +1708,7 @@ var CallTracker = class {
|
|
|
1673
1708
|
|
|
1674
1709
|
// src/commands/simulate/jsdom-executor.ts
|
|
1675
1710
|
import { JSDOM, VirtualConsole } from "jsdom";
|
|
1676
|
-
import
|
|
1711
|
+
import fs9 from "fs-extra";
|
|
1677
1712
|
function buildSandboxFromEnvs(envs, destinations, tracker) {
|
|
1678
1713
|
const baseBrowserMocks = {
|
|
1679
1714
|
Image: class MockImage {
|
|
@@ -1742,7 +1777,7 @@ async function executeInJSDOM(bundlePath, destinations, event, tracker, envs, ti
|
|
|
1742
1777
|
const sandbox = buildSandboxFromEnvs(envs, destinations, tracker);
|
|
1743
1778
|
Object.assign(window, sandbox.window);
|
|
1744
1779
|
Object.assign(window.document, sandbox.document);
|
|
1745
|
-
const bundleCode = await
|
|
1780
|
+
const bundleCode = await fs9.readFile(bundlePath, "utf8");
|
|
1746
1781
|
try {
|
|
1747
1782
|
window.eval(bundleCode);
|
|
1748
1783
|
} catch (error) {
|
|
@@ -1949,7 +1984,7 @@ async function executeSimulation(event, configPath) {
|
|
|
1949
1984
|
);
|
|
1950
1985
|
}
|
|
1951
1986
|
const typedEvent = event;
|
|
1952
|
-
await
|
|
1987
|
+
await fs10.ensureDir(tempDir);
|
|
1953
1988
|
const rawConfig = await loadJsonConfig(configPath);
|
|
1954
1989
|
const { flowConfig, buildOptions } = loadBundleConfig(rawConfig, {
|
|
1955
1990
|
configPath
|
|
@@ -2023,7 +2058,7 @@ async function executeSimulation(event, configPath) {
|
|
|
2023
2058
|
};
|
|
2024
2059
|
} finally {
|
|
2025
2060
|
if (tempDir) {
|
|
2026
|
-
await
|
|
2061
|
+
await fs10.remove(tempDir).catch(() => {
|
|
2027
2062
|
});
|
|
2028
2063
|
}
|
|
2029
2064
|
}
|
|
@@ -2101,7 +2136,7 @@ async function simulate(configOrPath, event, options = {}) {
|
|
|
2101
2136
|
// src/commands/push/index.ts
|
|
2102
2137
|
import path11 from "path";
|
|
2103
2138
|
import { JSDOM as JSDOM2, VirtualConsole as VirtualConsole2 } from "jsdom";
|
|
2104
|
-
import
|
|
2139
|
+
import fs11 from "fs-extra";
|
|
2105
2140
|
import { getPlatform as getPlatform3 } from "@walkeros/core";
|
|
2106
2141
|
import { schemas as schemas2 } from "@walkeros/core/dev";
|
|
2107
2142
|
async function pushCommand(options) {
|
|
@@ -2151,7 +2186,7 @@ async function pushCommand(options) {
|
|
|
2151
2186
|
".tmp",
|
|
2152
2187
|
`push-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`
|
|
2153
2188
|
);
|
|
2154
|
-
await
|
|
2189
|
+
await fs11.ensureDir(tempDir);
|
|
2155
2190
|
const tempPath = path11.join(
|
|
2156
2191
|
tempDir,
|
|
2157
2192
|
`bundle.${platform === "web" ? "js" : "mjs"}`
|
|
@@ -2216,7 +2251,7 @@ async function pushCommand(options) {
|
|
|
2216
2251
|
}
|
|
2217
2252
|
}
|
|
2218
2253
|
try {
|
|
2219
|
-
await
|
|
2254
|
+
await fs11.remove(tempDir);
|
|
2220
2255
|
} catch {
|
|
2221
2256
|
}
|
|
2222
2257
|
} catch (error) {
|
|
@@ -2261,7 +2296,7 @@ async function executeWebPush(bundlePath, event, logger2) {
|
|
|
2261
2296
|
});
|
|
2262
2297
|
const { window } = dom;
|
|
2263
2298
|
logger2.debug("Loading bundle...");
|
|
2264
|
-
const bundleCode = await
|
|
2299
|
+
const bundleCode = await fs11.readFile(bundlePath, "utf8");
|
|
2265
2300
|
window.eval(bundleCode);
|
|
2266
2301
|
logger2.debug("Waiting for elb...");
|
|
2267
2302
|
await waitForWindowProperty2(
|
|
@@ -2402,7 +2437,7 @@ function validatePort(port) {
|
|
|
2402
2437
|
|
|
2403
2438
|
// src/commands/run/utils.ts
|
|
2404
2439
|
import path12 from "path";
|
|
2405
|
-
import
|
|
2440
|
+
import fs12 from "fs-extra";
|
|
2406
2441
|
async function prepareBundleForRun(configPath, options) {
|
|
2407
2442
|
const configDir = path12.dirname(path12.resolve(configPath));
|
|
2408
2443
|
const tempDir = path12.join(
|
|
@@ -2410,7 +2445,7 @@ async function prepareBundleForRun(configPath, options) {
|
|
|
2410
2445
|
".tmp",
|
|
2411
2446
|
`run-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`
|
|
2412
2447
|
);
|
|
2413
|
-
await
|
|
2448
|
+
await fs12.ensureDir(tempDir);
|
|
2414
2449
|
const tempPath = path12.join(tempDir, "bundle.mjs");
|
|
2415
2450
|
await bundle(configPath, {
|
|
2416
2451
|
cache: true,
|
|
@@ -2597,20 +2632,20 @@ async function run(mode, options) {
|
|
|
2597
2632
|
}
|
|
2598
2633
|
|
|
2599
2634
|
// src/commands/cache.ts
|
|
2600
|
-
import
|
|
2635
|
+
import fs13 from "fs-extra";
|
|
2601
2636
|
import path14 from "path";
|
|
2602
2637
|
var CACHE_DIR = path14.join(".tmp", "cache");
|
|
2603
2638
|
function registerCacheCommand(program2) {
|
|
2604
2639
|
const cache = program2.command("cache").description("Manage the CLI cache");
|
|
2605
2640
|
cache.command("clear").description("Clear all cached packages and builds").option("--packages", "Clear only package cache").option("--builds", "Clear only build cache").action(async (options) => {
|
|
2606
2641
|
if (options.packages) {
|
|
2607
|
-
await
|
|
2642
|
+
await fs13.remove(path14.join(CACHE_DIR, "packages"));
|
|
2608
2643
|
console.log("Package cache cleared");
|
|
2609
2644
|
} else if (options.builds) {
|
|
2610
|
-
await
|
|
2645
|
+
await fs13.remove(path14.join(CACHE_DIR, "builds"));
|
|
2611
2646
|
console.log("Build cache cleared");
|
|
2612
2647
|
} else {
|
|
2613
|
-
await
|
|
2648
|
+
await fs13.remove(CACHE_DIR);
|
|
2614
2649
|
console.log("All caches cleared");
|
|
2615
2650
|
}
|
|
2616
2651
|
});
|
|
@@ -2625,18 +2660,12 @@ function registerCacheCommand(program2) {
|
|
|
2625
2660
|
});
|
|
2626
2661
|
}
|
|
2627
2662
|
async function countEntries(dir) {
|
|
2628
|
-
if (!await
|
|
2629
|
-
const entries = await
|
|
2663
|
+
if (!await fs13.pathExists(dir)) return 0;
|
|
2664
|
+
const entries = await fs13.readdir(dir);
|
|
2630
2665
|
return entries.length;
|
|
2631
2666
|
}
|
|
2632
2667
|
|
|
2633
2668
|
// src/index.ts
|
|
2634
|
-
var __filename = fileURLToPath2(import.meta.url);
|
|
2635
|
-
var __dirname = dirname(__filename);
|
|
2636
|
-
var packageJson = JSON.parse(
|
|
2637
|
-
readFileSync(join(__dirname, "../package.json"), "utf-8")
|
|
2638
|
-
);
|
|
2639
|
-
var VERSION = packageJson.version;
|
|
2640
2669
|
var program = new Command();
|
|
2641
2670
|
program.name("walkeros").description("walkerOS CLI - Bundle and deploy walkerOS components").version(VERSION);
|
|
2642
2671
|
program.hook("preAction", (thisCommand, actionCommand) => {
|