@b9g/libuild 0.1.3 → 0.1.5
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 +11 -13
- package/package.json +15 -15
- package/src/cli.cjs +62 -795
- package/src/cli.js +167 -11
- package/src/libuild.cjs +344 -183
- package/src/libuild.d.ts +1 -1
- package/src/libuild.js +934 -8
- package/src/chunk-EVLPGECD.js +0 -71
- package/src/chunk-EVLPGECD.js.map +0 -7
- package/src/chunk-YRPHTAV4.js +0 -713
- package/src/chunk-YRPHTAV4.js.map +0 -7
- package/src/cli.cjs.map +0 -7
- package/src/cli.js.map +0 -7
- package/src/libuild.cjs.map +0 -7
- package/src/libuild.js.map +0 -7
- package/src/package-4E3XK74J.js +0 -132
- package/src/package-4E3XK74J.js.map +0 -7
- package/src/umd-plugin.cjs +0 -105
- package/src/umd-plugin.cjs.map +0 -7
- package/src/umd-plugin.d.ts +0 -8
- package/src/umd-plugin.js +0 -8
- package/src/umd-plugin.js.map +0 -7
package/src/cli.js
CHANGED
|
@@ -1,13 +1,126 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/// <reference types="./cli.d.ts" />
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
10
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
|
|
29
|
+
// package.json
|
|
30
|
+
var require_package = __commonJS({
|
|
31
|
+
"package.json"(exports, module) {
|
|
32
|
+
module.exports = {
|
|
33
|
+
name: "@b9g/libuild",
|
|
34
|
+
version: "0.1.5",
|
|
35
|
+
description: "Zero-config library builds",
|
|
36
|
+
main: "./dist/src/libuild.cjs",
|
|
37
|
+
private: true,
|
|
38
|
+
bin: {
|
|
39
|
+
libuild: "./dist/src/cli.js"
|
|
40
|
+
},
|
|
41
|
+
type: "module",
|
|
42
|
+
scripts: {
|
|
43
|
+
build: "bun run src/cli.ts",
|
|
44
|
+
dev: "bun run src/cli.ts",
|
|
45
|
+
publish: "bun run src/cli.ts publish",
|
|
46
|
+
test: "bun test",
|
|
47
|
+
"test-src": "node test.js"
|
|
48
|
+
},
|
|
49
|
+
dependencies: {
|
|
50
|
+
esbuild: "^0.19.0"
|
|
51
|
+
},
|
|
52
|
+
peerDependencies: {
|
|
53
|
+
typescript: "^5.0.0"
|
|
54
|
+
},
|
|
55
|
+
peerDependenciesMeta: {
|
|
56
|
+
typescript: {
|
|
57
|
+
optional: true
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
devDependencies: {
|
|
61
|
+
"@types/bun": "latest",
|
|
62
|
+
typescript: "^5.0.0"
|
|
63
|
+
},
|
|
64
|
+
keywords: [
|
|
65
|
+
"build",
|
|
66
|
+
"library",
|
|
67
|
+
"bundler",
|
|
68
|
+
"bun",
|
|
69
|
+
"zero-config",
|
|
70
|
+
"typescript"
|
|
71
|
+
],
|
|
72
|
+
engines: {
|
|
73
|
+
bun: ">=1.0.0"
|
|
74
|
+
},
|
|
75
|
+
repository: {
|
|
76
|
+
type: "git",
|
|
77
|
+
url: "git+https://github.com/bikeshaving/libuild.git"
|
|
78
|
+
},
|
|
79
|
+
bugs: {
|
|
80
|
+
url: "https://github.com/bikeshaving/libuild/issues"
|
|
81
|
+
},
|
|
82
|
+
license: "MIT",
|
|
83
|
+
module: "./dist/src/libuild.js",
|
|
84
|
+
types: "./dist/src/libuild.d.ts",
|
|
85
|
+
exports: {
|
|
86
|
+
".": {
|
|
87
|
+
types: "./dist/src/libuild.d.ts",
|
|
88
|
+
import: "./dist/src/libuild.js",
|
|
89
|
+
require: "./dist/src/libuild.cjs"
|
|
90
|
+
},
|
|
91
|
+
"./cli": {
|
|
92
|
+
types: "./dist/src/cli.d.ts",
|
|
93
|
+
import: "./dist/src/cli.js",
|
|
94
|
+
require: "./dist/src/cli.cjs"
|
|
95
|
+
},
|
|
96
|
+
"./cli.js": {
|
|
97
|
+
types: "./dist/src/cli.d.ts",
|
|
98
|
+
import: "./dist/src/cli.js",
|
|
99
|
+
require: "./dist/src/cli.cjs"
|
|
100
|
+
},
|
|
101
|
+
"./libuild": {
|
|
102
|
+
types: "./dist/src/libuild.d.ts",
|
|
103
|
+
import: "./dist/src/libuild.js",
|
|
104
|
+
require: "./dist/src/libuild.cjs"
|
|
105
|
+
},
|
|
106
|
+
"./libuild.js": {
|
|
107
|
+
types: "./dist/src/libuild.d.ts",
|
|
108
|
+
import: "./dist/src/libuild.js",
|
|
109
|
+
require: "./dist/src/libuild.cjs"
|
|
110
|
+
},
|
|
111
|
+
"./package.json": "./dist/package.json"
|
|
112
|
+
},
|
|
113
|
+
files: [
|
|
114
|
+
"dist/",
|
|
115
|
+
"README.md"
|
|
116
|
+
]
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
});
|
|
8
120
|
|
|
9
121
|
// src/cli.ts
|
|
10
122
|
import { parseArgs } from "util";
|
|
123
|
+
import { build, publish } from "./libuild.js";
|
|
11
124
|
var { values, positionals } = parseArgs({
|
|
12
125
|
args: process.argv.slice(2),
|
|
13
126
|
options: {
|
|
@@ -16,13 +129,15 @@ var { values, positionals } = parseArgs({
|
|
|
16
129
|
save: { type: "boolean" },
|
|
17
130
|
"no-save": { type: "boolean" }
|
|
18
131
|
},
|
|
19
|
-
allowPositionals: true
|
|
132
|
+
allowPositionals: true,
|
|
133
|
+
strict: false
|
|
134
|
+
// Allow unknown options to be passed through
|
|
20
135
|
});
|
|
21
136
|
var HELP_TEXT = `
|
|
22
137
|
libuild - Zero-config library builds
|
|
23
138
|
|
|
24
139
|
Usage:
|
|
25
|
-
libuild [command]
|
|
140
|
+
libuild [command] [options]
|
|
26
141
|
|
|
27
142
|
Commands:
|
|
28
143
|
build Build the library (default command)
|
|
@@ -32,10 +147,13 @@ Options:
|
|
|
32
147
|
--save Update root package.json to point to dist files
|
|
33
148
|
--no-save Skip package.json updates (for publish command)
|
|
34
149
|
|
|
150
|
+
For publish command, all additional flags are forwarded to npm publish.
|
|
151
|
+
|
|
35
152
|
Examples:
|
|
36
153
|
libuild # Build the library
|
|
37
154
|
libuild build --save # Build and update package.json for npm link
|
|
38
155
|
libuild publish # Build and publish to npm
|
|
156
|
+
libuild publish --dry-run --tag beta # Build and publish with npm flags
|
|
39
157
|
`;
|
|
40
158
|
async function main() {
|
|
41
159
|
if (values.help) {
|
|
@@ -43,21 +161,60 @@ async function main() {
|
|
|
43
161
|
process.exit(0);
|
|
44
162
|
}
|
|
45
163
|
if (values.version) {
|
|
46
|
-
const pkg = await
|
|
164
|
+
const pkg = await Promise.resolve().then(() => __toESM(require_package(), 1));
|
|
47
165
|
console.log(pkg.version);
|
|
48
166
|
process.exit(0);
|
|
49
167
|
}
|
|
50
168
|
const command = positionals[0] || "build";
|
|
51
169
|
const cwd = process.cwd();
|
|
52
170
|
const shouldSave = values.save || command === "publish" && !values["no-save"];
|
|
171
|
+
const allowedNpmFlags = [
|
|
172
|
+
"--dry-run",
|
|
173
|
+
"--tag",
|
|
174
|
+
"--access",
|
|
175
|
+
"--registry",
|
|
176
|
+
"--otp",
|
|
177
|
+
"--provenance",
|
|
178
|
+
"--workspace",
|
|
179
|
+
"--workspaces",
|
|
180
|
+
"--include-workspace-root"
|
|
181
|
+
];
|
|
182
|
+
const rawExtraArgs = process.argv.slice(2).filter(
|
|
183
|
+
(arg) => !["build", "publish"].includes(arg) && !["--save", "--no-save", "--help", "-h", "--version", "-v"].includes(arg)
|
|
184
|
+
);
|
|
185
|
+
const extraArgs = [];
|
|
186
|
+
for (let i = 0; i < rawExtraArgs.length; i++) {
|
|
187
|
+
const arg = rawExtraArgs[i];
|
|
188
|
+
if (arg.startsWith("--")) {
|
|
189
|
+
const flagName = arg.split("=")[0];
|
|
190
|
+
if (allowedNpmFlags.includes(flagName)) {
|
|
191
|
+
extraArgs.push(arg);
|
|
192
|
+
if (!arg.includes("=") && ["--tag", "--access", "--registry", "--otp", "--workspace"].includes(flagName)) {
|
|
193
|
+
if (i + 1 < rawExtraArgs.length && !rawExtraArgs[i + 1].startsWith("--")) {
|
|
194
|
+
extraArgs.push(rawExtraArgs[i + 1]);
|
|
195
|
+
i++;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
} else {
|
|
199
|
+
console.warn(`Warning: Ignoring unknown/unsafe npm flag: ${arg}`);
|
|
200
|
+
}
|
|
201
|
+
} else {
|
|
202
|
+
const prevArg = i > 0 ? rawExtraArgs[i - 1] : "";
|
|
203
|
+
const isPrevArgValueFlag = ["--tag", "--access", "--registry", "--otp", "--workspace"].includes(prevArg) && !prevArg.includes("=");
|
|
204
|
+
if (isPrevArgValueFlag && extraArgs.includes(prevArg)) {
|
|
205
|
+
extraArgs.push(arg);
|
|
206
|
+
} else {
|
|
207
|
+
console.warn(`Warning: Ignoring unexpected argument: ${arg}`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
53
211
|
try {
|
|
54
212
|
switch (command) {
|
|
55
213
|
case "build":
|
|
56
214
|
await build(cwd, shouldSave);
|
|
57
215
|
break;
|
|
58
216
|
case "publish":
|
|
59
|
-
|
|
60
|
-
await publish(cwd, shouldSave);
|
|
217
|
+
await publish(cwd, shouldSave, extraArgs);
|
|
61
218
|
break;
|
|
62
219
|
default:
|
|
63
220
|
console.error(`Unknown command: ${command}`);
|
|
@@ -70,4 +227,3 @@ async function main() {
|
|
|
70
227
|
}
|
|
71
228
|
}
|
|
72
229
|
main();
|
|
73
|
-
//# sourceMappingURL=cli.js.map
|