@b9g/libuild 0.1.9 → 0.1.10
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/package.json +1 -1
- package/src/cli.cjs +6 -0
- package/src/cli.js +6 -0
- package/src/libuild.cjs +40 -15
- package/src/libuild.js +40 -15
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.1.10] - 2025-10-29
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- Automatic cleanup of invalid bin/exports paths when using --save flag
|
|
9
|
+
- Clear messaging that libuild is zero-config with NO libuild.config.js file
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
- --save now validates and removes bin/exports entries pointing to non-existent files
|
|
13
|
+
- Package.json fields are regenerated based on actual built files during --save
|
|
14
|
+
- Validation logic is now context-aware of --save flag to prevent warnings about configuration that libuild itself creates
|
|
15
|
+
- CLI argument parsing to prevent npm flags from being incorrectly treated as directory arguments
|
|
16
|
+
|
|
5
17
|
## [0.1.9] - 2025-10-29
|
|
6
18
|
|
|
7
19
|
### Fixed
|
package/package.json
CHANGED
package/src/cli.cjs
CHANGED
|
@@ -56,6 +56,12 @@ Options:
|
|
|
56
56
|
--save Update root package.json to point to dist files
|
|
57
57
|
--no-save Skip package.json updates (for publish command)
|
|
58
58
|
|
|
59
|
+
IMPORTANT:
|
|
60
|
+
\u2022 libuild is zero-config - there is NO libuild.config.js file
|
|
61
|
+
\u2022 Configuration comes from your package.json (main, module, exports, etc.)
|
|
62
|
+
\u2022 Use --save to regenerate package.json fields based on built files
|
|
63
|
+
\u2022 Invalid bin/exports paths are automatically cleaned up with --save
|
|
64
|
+
|
|
59
65
|
For publish command, all additional flags are forwarded to npm publish.
|
|
60
66
|
|
|
61
67
|
Examples:
|
package/src/cli.js
CHANGED
|
@@ -34,6 +34,12 @@ Options:
|
|
|
34
34
|
--save Update root package.json to point to dist files
|
|
35
35
|
--no-save Skip package.json updates (for publish command)
|
|
36
36
|
|
|
37
|
+
IMPORTANT:
|
|
38
|
+
\u2022 libuild is zero-config - there is NO libuild.config.js file
|
|
39
|
+
\u2022 Configuration comes from your package.json (main, module, exports, etc.)
|
|
40
|
+
\u2022 Use --save to regenerate package.json fields based on built files
|
|
41
|
+
\u2022 Invalid bin/exports paths are automatically cleaned up with --save
|
|
42
|
+
|
|
37
43
|
For publish command, all additional flags are forwarded to npm publish.
|
|
38
44
|
|
|
39
45
|
Examples:
|
package/src/libuild.cjs
CHANGED
|
@@ -215508,6 +215508,10 @@ If you need to include pre-built executable files, use the files field instead:
|
|
|
215508
215508
|
"files": ["scripts/my-tool.js"]`);
|
|
215509
215509
|
}
|
|
215510
215510
|
console.warn(`\u26A0\uFE0F WARNING: ${fieldName} field points to dist/ directory: "${binPath}"
|
|
215511
|
+
|
|
215512
|
+
libuild is ZERO-CONFIG - there is no libuild.config.js file!
|
|
215513
|
+
Configuration comes from your package.json fields.
|
|
215514
|
+
|
|
215511
215515
|
The libuild workflow is to point bin entries to src/ files and use --save to update paths.
|
|
215512
215516
|
Consider changing to: "${srcPath}" and running 'libuild build --save'`);
|
|
215513
215517
|
return;
|
|
@@ -215667,6 +215671,7 @@ function validatePath(inputPath, basePath) {
|
|
|
215667
215671
|
}
|
|
215668
215672
|
async function build2(cwd, save = false) {
|
|
215669
215673
|
console.info("Building with libuild...");
|
|
215674
|
+
console.info(" Zero-config library build tool - configuration from package.json");
|
|
215670
215675
|
const srcDir = Path3.join(cwd, "src");
|
|
215671
215676
|
const distDir = Path3.join(cwd, "dist");
|
|
215672
215677
|
const distSrcDir = Path3.join(distDir, "src");
|
|
@@ -215832,7 +215837,8 @@ async function build2(cwd, save = false) {
|
|
|
215832
215837
|
if (save) {
|
|
215833
215838
|
console.info(" Removing stale exports from root package.json (--save mode)");
|
|
215834
215839
|
} else {
|
|
215835
|
-
console.warn("
|
|
215840
|
+
console.warn(" libuild is ZERO-CONFIG - no libuild.config.js file needed!");
|
|
215841
|
+
console.warn(" Use 'libuild build --save' to clean up package.json automatically");
|
|
215836
215842
|
}
|
|
215837
215843
|
}
|
|
215838
215844
|
if (cleanedPkg.files && Array.isArray(cleanedPkg.files)) {
|
|
@@ -215929,36 +215935,55 @@ async function build2(cwd, save = false) {
|
|
|
215929
215935
|
const rootExports = {};
|
|
215930
215936
|
for (const [key, value] of Object.entries(cleanedPkg.exports)) {
|
|
215931
215937
|
if (typeof value === "string") {
|
|
215932
|
-
|
|
215938
|
+
const distPath = value.startsWith("./dist/") ? value : `./dist${value.startsWith(".") ? value.slice(1) : value}`;
|
|
215939
|
+
const fullPath = Path3.join(cwd, distPath);
|
|
215940
|
+
if (await fileExists(fullPath)) {
|
|
215941
|
+
rootExports[key] = distPath;
|
|
215942
|
+
}
|
|
215933
215943
|
} else if (typeof value === "object" && value !== null) {
|
|
215934
|
-
|
|
215944
|
+
const cleanedValue = {};
|
|
215945
|
+
let hasValidPaths = false;
|
|
215935
215946
|
for (const [subKey, subValue] of Object.entries(value)) {
|
|
215936
215947
|
if (typeof subValue === "string") {
|
|
215937
|
-
|
|
215948
|
+
const distPath = subValue.startsWith("./dist/") ? subValue : `./dist${subValue.startsWith(".") ? subValue.slice(1) : subValue}`;
|
|
215949
|
+
const fullPath = Path3.join(cwd, distPath);
|
|
215950
|
+
if (await fileExists(fullPath)) {
|
|
215951
|
+
cleanedValue[subKey] = distPath;
|
|
215952
|
+
hasValidPaths = true;
|
|
215953
|
+
}
|
|
215938
215954
|
}
|
|
215939
215955
|
}
|
|
215956
|
+
if (hasValidPaths) {
|
|
215957
|
+
rootExports[key] = cleanedValue;
|
|
215958
|
+
}
|
|
215940
215959
|
}
|
|
215941
215960
|
}
|
|
215942
215961
|
rootPkg2.exports = rootExports;
|
|
215943
215962
|
if (rootPkg2.bin) {
|
|
215944
215963
|
if (typeof rootPkg2.bin === "string") {
|
|
215945
|
-
|
|
215946
|
-
|
|
215947
|
-
|
|
215948
|
-
|
|
215949
|
-
|
|
215950
|
-
|
|
215964
|
+
const distPath = rootPkg2.bin.startsWith("./dist/") ? rootPkg2.bin : rootPkg2.bin.startsWith("dist/") ? "./" + rootPkg2.bin : "./" + Path3.join("dist", rootPkg2.bin);
|
|
215965
|
+
const fullPath = Path3.join(cwd, distPath);
|
|
215966
|
+
if (await fileExists(fullPath)) {
|
|
215967
|
+
rootPkg2.bin = distPath;
|
|
215968
|
+
} else {
|
|
215969
|
+
delete rootPkg2.bin;
|
|
215951
215970
|
}
|
|
215952
215971
|
} else {
|
|
215972
|
+
const cleanedBin = {};
|
|
215953
215973
|
for (const [name, binPath] of Object.entries(rootPkg2.bin)) {
|
|
215954
|
-
if (typeof binPath === "string"
|
|
215955
|
-
|
|
215956
|
-
|
|
215957
|
-
|
|
215958
|
-
|
|
215974
|
+
if (typeof binPath === "string") {
|
|
215975
|
+
const distPath = binPath.startsWith("./dist/") ? binPath : binPath.startsWith("dist/") ? "./" + binPath : "./" + Path3.join("dist", binPath);
|
|
215976
|
+
const fullPath = Path3.join(cwd, distPath);
|
|
215977
|
+
if (await fileExists(fullPath)) {
|
|
215978
|
+
cleanedBin[name] = distPath;
|
|
215959
215979
|
}
|
|
215960
215980
|
}
|
|
215961
215981
|
}
|
|
215982
|
+
if (Object.keys(cleanedBin).length > 0) {
|
|
215983
|
+
rootPkg2.bin = cleanedBin;
|
|
215984
|
+
} else {
|
|
215985
|
+
delete rootPkg2.bin;
|
|
215986
|
+
}
|
|
215962
215987
|
}
|
|
215963
215988
|
}
|
|
215964
215989
|
if (pkg.files !== void 0) {
|
package/src/libuild.js
CHANGED
|
@@ -487,6 +487,10 @@ If you need to include pre-built executable files, use the files field instead:
|
|
|
487
487
|
"files": ["scripts/my-tool.js"]`);
|
|
488
488
|
}
|
|
489
489
|
console.warn(`\u26A0\uFE0F WARNING: ${fieldName} field points to dist/ directory: "${binPath}"
|
|
490
|
+
|
|
491
|
+
libuild is ZERO-CONFIG - there is no libuild.config.js file!
|
|
492
|
+
Configuration comes from your package.json fields.
|
|
493
|
+
|
|
490
494
|
The libuild workflow is to point bin entries to src/ files and use --save to update paths.
|
|
491
495
|
Consider changing to: "${srcPath}" and running 'libuild build --save'`);
|
|
492
496
|
return;
|
|
@@ -646,6 +650,7 @@ function validatePath(inputPath, basePath) {
|
|
|
646
650
|
}
|
|
647
651
|
async function build2(cwd, save = false) {
|
|
648
652
|
console.info("Building with libuild...");
|
|
653
|
+
console.info(" Zero-config library build tool - configuration from package.json");
|
|
649
654
|
const srcDir = Path3.join(cwd, "src");
|
|
650
655
|
const distDir = Path3.join(cwd, "dist");
|
|
651
656
|
const distSrcDir = Path3.join(distDir, "src");
|
|
@@ -811,7 +816,8 @@ async function build2(cwd, save = false) {
|
|
|
811
816
|
if (save) {
|
|
812
817
|
console.info(" Removing stale exports from root package.json (--save mode)");
|
|
813
818
|
} else {
|
|
814
|
-
console.warn("
|
|
819
|
+
console.warn(" libuild is ZERO-CONFIG - no libuild.config.js file needed!");
|
|
820
|
+
console.warn(" Use 'libuild build --save' to clean up package.json automatically");
|
|
815
821
|
}
|
|
816
822
|
}
|
|
817
823
|
if (cleanedPkg.files && Array.isArray(cleanedPkg.files)) {
|
|
@@ -908,36 +914,55 @@ async function build2(cwd, save = false) {
|
|
|
908
914
|
const rootExports = {};
|
|
909
915
|
for (const [key, value] of Object.entries(cleanedPkg.exports)) {
|
|
910
916
|
if (typeof value === "string") {
|
|
911
|
-
|
|
917
|
+
const distPath = value.startsWith("./dist/") ? value : `./dist${value.startsWith(".") ? value.slice(1) : value}`;
|
|
918
|
+
const fullPath = Path3.join(cwd, distPath);
|
|
919
|
+
if (await fileExists(fullPath)) {
|
|
920
|
+
rootExports[key] = distPath;
|
|
921
|
+
}
|
|
912
922
|
} else if (typeof value === "object" && value !== null) {
|
|
913
|
-
|
|
923
|
+
const cleanedValue = {};
|
|
924
|
+
let hasValidPaths = false;
|
|
914
925
|
for (const [subKey, subValue] of Object.entries(value)) {
|
|
915
926
|
if (typeof subValue === "string") {
|
|
916
|
-
|
|
927
|
+
const distPath = subValue.startsWith("./dist/") ? subValue : `./dist${subValue.startsWith(".") ? subValue.slice(1) : subValue}`;
|
|
928
|
+
const fullPath = Path3.join(cwd, distPath);
|
|
929
|
+
if (await fileExists(fullPath)) {
|
|
930
|
+
cleanedValue[subKey] = distPath;
|
|
931
|
+
hasValidPaths = true;
|
|
932
|
+
}
|
|
917
933
|
}
|
|
918
934
|
}
|
|
935
|
+
if (hasValidPaths) {
|
|
936
|
+
rootExports[key] = cleanedValue;
|
|
937
|
+
}
|
|
919
938
|
}
|
|
920
939
|
}
|
|
921
940
|
rootPkg2.exports = rootExports;
|
|
922
941
|
if (rootPkg2.bin) {
|
|
923
942
|
if (typeof rootPkg2.bin === "string") {
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
943
|
+
const distPath = rootPkg2.bin.startsWith("./dist/") ? rootPkg2.bin : rootPkg2.bin.startsWith("dist/") ? "./" + rootPkg2.bin : "./" + Path3.join("dist", rootPkg2.bin);
|
|
944
|
+
const fullPath = Path3.join(cwd, distPath);
|
|
945
|
+
if (await fileExists(fullPath)) {
|
|
946
|
+
rootPkg2.bin = distPath;
|
|
947
|
+
} else {
|
|
948
|
+
delete rootPkg2.bin;
|
|
930
949
|
}
|
|
931
950
|
} else {
|
|
951
|
+
const cleanedBin = {};
|
|
932
952
|
for (const [name, binPath] of Object.entries(rootPkg2.bin)) {
|
|
933
|
-
if (typeof binPath === "string"
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
953
|
+
if (typeof binPath === "string") {
|
|
954
|
+
const distPath = binPath.startsWith("./dist/") ? binPath : binPath.startsWith("dist/") ? "./" + binPath : "./" + Path3.join("dist", binPath);
|
|
955
|
+
const fullPath = Path3.join(cwd, distPath);
|
|
956
|
+
if (await fileExists(fullPath)) {
|
|
957
|
+
cleanedBin[name] = distPath;
|
|
938
958
|
}
|
|
939
959
|
}
|
|
940
960
|
}
|
|
961
|
+
if (Object.keys(cleanedBin).length > 0) {
|
|
962
|
+
rootPkg2.bin = cleanedBin;
|
|
963
|
+
} else {
|
|
964
|
+
delete rootPkg2.bin;
|
|
965
|
+
}
|
|
941
966
|
}
|
|
942
967
|
}
|
|
943
968
|
if (pkg.files !== void 0) {
|