@overlayed/cli 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +4 -1679
- package/package.json +8 -4
- package/.attest/assertions/typescript.json +0 -1
- package/__mocks__/fs/promises.cjs +0 -2
- package/__mocks__/fs.cjs +0 -2
- package/__tests__/bundler.test.ts +0 -457
- package/__tests__/temp.test.ts +0 -7
- package/__tests__/utils.ts +0 -2
- package/dist/chunk-RDQt0V5E.js +0 -31
- package/dist/lib-DalWKwNu.js +0 -1041
- package/moon.yml +0 -18
- package/setupVitest.ts +0 -5
- package/src/bundle/command.ts +0 -87
- package/src/bundle/internal/appBundler.ts +0 -35
- package/src/bundle/internal/bundler.ts +0 -77
- package/src/bundle/internal/isBundleConfig.ts +0 -6
- package/src/cli.ts +0 -4
- package/src/consts.ts +0 -3
- package/temp/myfile.txt +0 -0
- package/temp/overlayed.config.ts +0 -8
- package/temp/someotherfile.ts +0 -0
- package/tsconfig.build.json +0 -8
- package/tsconfig.json +0 -38
- package/tsdown.config.ts +0 -13
- package/vitest.config.ts +0 -17
package/package.json
CHANGED
|
@@ -9,25 +9,29 @@
|
|
|
9
9
|
"keywords": [
|
|
10
10
|
"typescript"
|
|
11
11
|
],
|
|
12
|
-
"version": "0.0.
|
|
12
|
+
"version": "0.0.3",
|
|
13
13
|
"description": "Overlayed CLI",
|
|
14
14
|
"packageManager": "pnpm@10.6.3",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"bin": {
|
|
17
17
|
"ogg": "./dist/cli.js"
|
|
18
18
|
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist/**/*"
|
|
21
|
+
],
|
|
19
22
|
"devDependencies": {
|
|
20
23
|
"@ark/attest": "^0.45.0",
|
|
24
|
+
"@overlayed/utils": "workspace:*",
|
|
25
|
+
"@overlayed/utils-node": "workspace:*",
|
|
21
26
|
"@types/fs-extra": "^11.0.4",
|
|
22
|
-
"clipanion": "4.0.0-rc.4",
|
|
23
27
|
"tsdown": "^0.12.9",
|
|
24
28
|
"typescript": "^5.8.2",
|
|
25
29
|
"vitest": "^3.0.9"
|
|
26
30
|
},
|
|
27
31
|
"dependencies": {
|
|
28
|
-
"
|
|
29
|
-
"@overlayed/utils-node": "workspace:*",
|
|
32
|
+
"arktype": "^2.1.20",
|
|
30
33
|
"chalk": "^5.4.1",
|
|
34
|
+
"clipanion": "4.0.0-rc.4",
|
|
31
35
|
"fs-extra": "^11.3.0",
|
|
32
36
|
"glob": "^11.0.3",
|
|
33
37
|
"jszip": "^3.10.1"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{}
|
package/__mocks__/fs.cjs
DELETED
|
@@ -1,457 +0,0 @@
|
|
|
1
|
-
import { describe, beforeEach, afterEach, it, expect, vi, type MockedFunction } from "vitest";
|
|
2
|
-
import { vol } from "memfs";
|
|
3
|
-
import { Bundler } from "../src/bundle/internal/bundler";
|
|
4
|
-
import { AppBundler } from "../src/bundle/internal/appBundler";
|
|
5
|
-
import { glob } from "glob";
|
|
6
|
-
import path from "node:path";
|
|
7
|
-
|
|
8
|
-
vi.mock("node:fs");
|
|
9
|
-
vi.mock("glob");
|
|
10
|
-
|
|
11
|
-
const mockGlob = glob as MockedFunction<typeof glob>;
|
|
12
|
-
|
|
13
|
-
describe("Bundler", () => {
|
|
14
|
-
let bundler: Bundler;
|
|
15
|
-
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
vol.reset();
|
|
18
|
-
bundler = new Bundler();
|
|
19
|
-
vi.clearAllMocks();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
afterEach(() => {
|
|
23
|
-
vi.clearAllMocks();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
describe("addGlobPattern", () => {
|
|
27
|
-
it("should add a single string pattern", () => {
|
|
28
|
-
bundler.addGlobPattern("*.js");
|
|
29
|
-
// Test passes if no error is thrown
|
|
30
|
-
expect(bundler).toBeDefined();
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("should add an array of patterns", () => {
|
|
34
|
-
bundler.addGlobPattern(["*.js", "*.ts"]);
|
|
35
|
-
// Test passes if no error is thrown
|
|
36
|
-
expect(bundler).toBeDefined();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("should add pattern with options", () => {
|
|
40
|
-
bundler.addGlobPattern("*.js", { ignore: ["node_modules/**"] });
|
|
41
|
-
// Test passes if no error is thrown
|
|
42
|
-
expect(bundler).toBeDefined();
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("should add multiple patterns", () => {
|
|
46
|
-
bundler.addGlobPattern("*.js");
|
|
47
|
-
bundler.addGlobPattern(["*.ts", "*.json"]);
|
|
48
|
-
bundler.addGlobPattern("*.md", { ignore: ["README.md"] });
|
|
49
|
-
// Test passes if no error is thrown
|
|
50
|
-
expect(bundler).toBeDefined();
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
describe("bundle", () => {
|
|
55
|
-
beforeEach(() => {
|
|
56
|
-
// Set up a mock file system with current working directory paths
|
|
57
|
-
const testCwd = process.cwd();
|
|
58
|
-
vol.fromJSON({
|
|
59
|
-
[path.join(testCwd, "file1.js")]: "console.log('file1');",
|
|
60
|
-
[path.join(testCwd, "file2.js")]: "console.log('file2');",
|
|
61
|
-
[path.join(testCwd, "src", "index.ts")]: "export const hello = 'world';",
|
|
62
|
-
[path.join(testCwd, "src", "utils.ts")]: "export const utils = true;",
|
|
63
|
-
[path.join(testCwd, "package.json")]: '{"name": "test-project"}',
|
|
64
|
-
[path.join(testCwd, "README.md")]: "# Test Project",
|
|
65
|
-
[path.join(testCwd, "node_modules", "dep", "index.js")]: "module.exports = {};",
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it("should bundle files matching a single pattern", async () => {
|
|
70
|
-
const testCwd = process.cwd();
|
|
71
|
-
mockGlob.mockResolvedValueOnce([path.join(testCwd, "file1.js"), path.join(testCwd, "file2.js")]);
|
|
72
|
-
|
|
73
|
-
bundler.addGlobPattern("*.js");
|
|
74
|
-
const zip = await bundler.bundle();
|
|
75
|
-
|
|
76
|
-
expect(mockGlob).toHaveBeenCalledWith(
|
|
77
|
-
["*.js"],
|
|
78
|
-
expect.objectContaining({
|
|
79
|
-
absolute: true,
|
|
80
|
-
cwd: testCwd,
|
|
81
|
-
}),
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
const files = Object.keys(zip.files);
|
|
85
|
-
expect(files).toContain("file1.js");
|
|
86
|
-
expect(files).toContain("file2.js");
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it("should bundle files matching multiple patterns", async () => {
|
|
90
|
-
const testCwd = process.cwd();
|
|
91
|
-
mockGlob
|
|
92
|
-
.mockResolvedValueOnce([path.join(testCwd, "file1.js"), path.join(testCwd, "file2.js")])
|
|
93
|
-
.mockResolvedValueOnce([path.join(testCwd, "src", "index.ts"), path.join(testCwd, "src", "utils.ts")]);
|
|
94
|
-
|
|
95
|
-
bundler.addGlobPattern("*.js");
|
|
96
|
-
bundler.addGlobPattern("src/*.ts");
|
|
97
|
-
const zip = await bundler.bundle();
|
|
98
|
-
|
|
99
|
-
expect(mockGlob).toHaveBeenCalledTimes(2);
|
|
100
|
-
expect(mockGlob).toHaveBeenNthCalledWith(1, ["*.js"], expect.any(Object));
|
|
101
|
-
expect(mockGlob).toHaveBeenNthCalledWith(2, ["src/*.ts"], expect.any(Object));
|
|
102
|
-
|
|
103
|
-
const files = Object.keys(zip.files);
|
|
104
|
-
expect(files).toContain("file1.js");
|
|
105
|
-
expect(files).toContain("file2.js");
|
|
106
|
-
expect(files).toContain(path.join("src", "index.ts"));
|
|
107
|
-
expect(files).toContain(path.join("src", "utils.ts"));
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it("should handle array patterns", async () => {
|
|
111
|
-
const testCwd = process.cwd();
|
|
112
|
-
mockGlob.mockResolvedValueOnce([path.join(testCwd, "file1.js"), path.join(testCwd, "src", "index.ts")]);
|
|
113
|
-
|
|
114
|
-
bundler.addGlobPattern(["*.js", "src/*.ts"]);
|
|
115
|
-
const zip = await bundler.bundle();
|
|
116
|
-
|
|
117
|
-
expect(mockGlob).toHaveBeenCalledWith(["*.js", "src/*.ts"], expect.any(Object));
|
|
118
|
-
|
|
119
|
-
const files = Object.keys(zip.files);
|
|
120
|
-
expect(files).toContain("file1.js");
|
|
121
|
-
expect(files).toContain(path.join("src", "index.ts"));
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it("should respect glob options", async () => {
|
|
125
|
-
const testCwd = process.cwd();
|
|
126
|
-
mockGlob.mockResolvedValueOnce([path.join(testCwd, "file1.js")]);
|
|
127
|
-
|
|
128
|
-
const options = { ignore: ["node_modules/**"] };
|
|
129
|
-
bundler.addGlobPattern("**/*.js", options);
|
|
130
|
-
await bundler.bundle();
|
|
131
|
-
|
|
132
|
-
expect(mockGlob).toHaveBeenCalledWith(
|
|
133
|
-
["**/*.js"],
|
|
134
|
-
expect.objectContaining({
|
|
135
|
-
ignore: ["node_modules/**"],
|
|
136
|
-
absolute: true,
|
|
137
|
-
}),
|
|
138
|
-
);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it("should use provided cwd option", async () => {
|
|
142
|
-
const customCwd = path.resolve("custom", "path");
|
|
143
|
-
mockGlob.mockResolvedValueOnce([path.join(customCwd, "file.js")]);
|
|
144
|
-
|
|
145
|
-
bundler.addGlobPattern("*.js", { cwd: customCwd });
|
|
146
|
-
await bundler.bundle();
|
|
147
|
-
|
|
148
|
-
expect(mockGlob).toHaveBeenCalledWith(
|
|
149
|
-
["*.js"],
|
|
150
|
-
expect.objectContaining({
|
|
151
|
-
cwd: customCwd,
|
|
152
|
-
absolute: true,
|
|
153
|
-
}),
|
|
154
|
-
);
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
it("should handle URL cwd option", async () => {
|
|
158
|
-
const testCwd = path.resolve("url", "path");
|
|
159
|
-
// Create the directory structure in the mock filesystem
|
|
160
|
-
vol.mkdirSync(testCwd, { recursive: true });
|
|
161
|
-
vol.writeFileSync(path.join(testCwd, "file.js"), "test");
|
|
162
|
-
|
|
163
|
-
mockGlob.mockResolvedValueOnce([path.join(testCwd, "file.js")]);
|
|
164
|
-
|
|
165
|
-
const urlCwd = new URL(`file:///${testCwd.replace(/\\/g, "/")}`);
|
|
166
|
-
bundler.addGlobPattern("*.js", { cwd: urlCwd });
|
|
167
|
-
await bundler.bundle();
|
|
168
|
-
|
|
169
|
-
expect(mockGlob).toHaveBeenCalledWith(
|
|
170
|
-
["*.js"],
|
|
171
|
-
expect.objectContaining({
|
|
172
|
-
cwd: testCwd,
|
|
173
|
-
absolute: true,
|
|
174
|
-
}),
|
|
175
|
-
);
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
it("should resolve relative cwd paths", async () => {
|
|
179
|
-
mockGlob.mockResolvedValueOnce([]);
|
|
180
|
-
|
|
181
|
-
bundler.addGlobPattern("*.js", { cwd: "./relative/path" });
|
|
182
|
-
await bundler.bundle();
|
|
183
|
-
|
|
184
|
-
expect(mockGlob).toHaveBeenCalledWith(
|
|
185
|
-
["*.js"],
|
|
186
|
-
expect.objectContaining({
|
|
187
|
-
cwd: path.resolve("./relative/path"),
|
|
188
|
-
absolute: true,
|
|
189
|
-
}),
|
|
190
|
-
);
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
it("should create zip with correct file paths relative to cwd", async () => {
|
|
194
|
-
const testCwd = path.resolve("project");
|
|
195
|
-
vol.mkdirSync(path.join(testCwd, "src"), { recursive: true });
|
|
196
|
-
vol.writeFileSync(path.join(testCwd, "src", "index.ts"), "test content");
|
|
197
|
-
vol.writeFileSync(path.join(testCwd, "package.json"), "{}");
|
|
198
|
-
|
|
199
|
-
mockGlob.mockResolvedValueOnce([path.join(testCwd, "src", "index.ts"), path.join(testCwd, "package.json")]);
|
|
200
|
-
|
|
201
|
-
bundler.addGlobPattern("**/*", { cwd: testCwd });
|
|
202
|
-
const zip = await bundler.bundle();
|
|
203
|
-
|
|
204
|
-
const files = Object.keys(zip.files);
|
|
205
|
-
expect(files).toContain(path.join("src", "index.ts"));
|
|
206
|
-
expect(files).toContain("package.json");
|
|
207
|
-
// Ensure absolute paths are not used
|
|
208
|
-
expect(files.every((f) => !path.isAbsolute(f))).toBe(true);
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
it("should handle empty glob results", async () => {
|
|
212
|
-
mockGlob.mockResolvedValueOnce([]);
|
|
213
|
-
|
|
214
|
-
bundler.addGlobPattern("*.nonexistent");
|
|
215
|
-
const zip = await bundler.bundle();
|
|
216
|
-
|
|
217
|
-
expect(Object.keys(zip.files)).toHaveLength(0);
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
it("should handle multiple patterns with some empty results", async () => {
|
|
221
|
-
const testCwd = process.cwd();
|
|
222
|
-
mockGlob.mockResolvedValueOnce([path.join(testCwd, "file1.js")]).mockResolvedValueOnce([]);
|
|
223
|
-
|
|
224
|
-
bundler.addGlobPattern("*.js");
|
|
225
|
-
bundler.addGlobPattern("*.nonexistent");
|
|
226
|
-
const zip = await bundler.bundle();
|
|
227
|
-
|
|
228
|
-
const files = Object.keys(zip.files);
|
|
229
|
-
expect(files).toContain("file1.js");
|
|
230
|
-
expect(files).toHaveLength(1);
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
it("should use DEFLATE compression", async () => {
|
|
234
|
-
const testCwd = process.cwd();
|
|
235
|
-
mockGlob.mockResolvedValueOnce([path.join(testCwd, "file1.js")]);
|
|
236
|
-
|
|
237
|
-
bundler.addGlobPattern("*.js");
|
|
238
|
-
const zip = await bundler.bundle();
|
|
239
|
-
|
|
240
|
-
const files = Object.keys(zip.files);
|
|
241
|
-
expect(files).toHaveLength(1);
|
|
242
|
-
|
|
243
|
-
const file = zip.files[files[0]];
|
|
244
|
-
expect(file).toBeDefined();
|
|
245
|
-
expect(file.options.compression).toBe("DEFLATE");
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
it("should handle glob errors gracefully", async () => {
|
|
249
|
-
const error = new Error("Glob failed");
|
|
250
|
-
mockGlob.mockRejectedValueOnce(error);
|
|
251
|
-
|
|
252
|
-
bundler.addGlobPattern("*.js");
|
|
253
|
-
|
|
254
|
-
await expect(bundler.bundle()).rejects.toThrow("Glob failed");
|
|
255
|
-
});
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
describe("AppBundler", () => {
|
|
259
|
-
let appBundler: AppBundler;
|
|
260
|
-
|
|
261
|
-
beforeEach(() => {
|
|
262
|
-
vol.reset();
|
|
263
|
-
appBundler = new AppBundler();
|
|
264
|
-
vi.clearAllMocks();
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
describe("constructor", () => {
|
|
268
|
-
it("should automatically include package.json pattern", () => {
|
|
269
|
-
// Test passes if no error is thrown during construction
|
|
270
|
-
// The package.json pattern is added in constructor
|
|
271
|
-
expect(appBundler).toBeDefined();
|
|
272
|
-
});
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
describe("installer folder exclusion", () => {
|
|
276
|
-
beforeEach(() => {
|
|
277
|
-
const testCwd = process.cwd();
|
|
278
|
-
vol.fromJSON({
|
|
279
|
-
[path.join(testCwd, "package.json")]: '{"name": "test-app"}',
|
|
280
|
-
[path.join(testCwd, "src", "index.js")]: "console.log('app');",
|
|
281
|
-
[path.join(testCwd, "installer", "setup.exe")]: "binary content",
|
|
282
|
-
[path.join(testCwd, "installer", "data", "config.json")]: '{"setup": true}',
|
|
283
|
-
[path.join(testCwd, "nested", "installer", "tool.exe")]: "tool content",
|
|
284
|
-
[path.join(testCwd, "dist", "app.js")]: "built app",
|
|
285
|
-
});
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
it("should exclude installer folder when no ignore options provided", async () => {
|
|
289
|
-
const testCwd = process.cwd();
|
|
290
|
-
// Mock package.json call (first call for auto-added pattern)
|
|
291
|
-
mockGlob.mockResolvedValueOnce([path.join(testCwd, "package.json")]);
|
|
292
|
-
// Mock user pattern call
|
|
293
|
-
mockGlob.mockResolvedValueOnce([
|
|
294
|
-
path.join(testCwd, "src", "index.js"),
|
|
295
|
-
path.join(testCwd, "dist", "app.js"),
|
|
296
|
-
]);
|
|
297
|
-
|
|
298
|
-
appBundler.addGlobPattern("**/*.js");
|
|
299
|
-
const zip = await appBundler.bundle();
|
|
300
|
-
|
|
301
|
-
expect(mockGlob).toHaveBeenNthCalledWith(
|
|
302
|
-
2,
|
|
303
|
-
["**/*.js"],
|
|
304
|
-
expect.objectContaining({
|
|
305
|
-
ignore: "**/installer/**",
|
|
306
|
-
}),
|
|
307
|
-
);
|
|
308
|
-
|
|
309
|
-
const files = Object.keys(zip.files);
|
|
310
|
-
expect(files).toContain("package.json");
|
|
311
|
-
expect(files).toContain(path.join("src", "index.js"));
|
|
312
|
-
expect(files).toContain(path.join("dist", "app.js"));
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
it("should merge installer exclusion with existing ignore patterns (string)", async () => {
|
|
316
|
-
const testCwd = process.cwd();
|
|
317
|
-
mockGlob.mockResolvedValueOnce([path.join(testCwd, "package.json")]);
|
|
318
|
-
mockGlob.mockResolvedValueOnce([path.join(testCwd, "src", "index.js")]);
|
|
319
|
-
|
|
320
|
-
appBundler.addGlobPattern("**/*.js", { ignore: "node_modules/**" });
|
|
321
|
-
await appBundler.bundle();
|
|
322
|
-
|
|
323
|
-
expect(mockGlob).toHaveBeenNthCalledWith(
|
|
324
|
-
2,
|
|
325
|
-
["**/*.js"],
|
|
326
|
-
expect.objectContaining({
|
|
327
|
-
ignore: ["node_modules/**", "**/installer/**"],
|
|
328
|
-
}),
|
|
329
|
-
);
|
|
330
|
-
});
|
|
331
|
-
|
|
332
|
-
it("should merge installer exclusion with existing ignore patterns (array)", async () => {
|
|
333
|
-
const testCwd = process.cwd();
|
|
334
|
-
mockGlob.mockResolvedValueOnce([path.join(testCwd, "package.json")]);
|
|
335
|
-
mockGlob.mockResolvedValueOnce([path.join(testCwd, "src", "index.js")]);
|
|
336
|
-
|
|
337
|
-
appBundler.addGlobPattern("**/*.js", {
|
|
338
|
-
ignore: ["node_modules/**", "*.test.js"],
|
|
339
|
-
});
|
|
340
|
-
await appBundler.bundle();
|
|
341
|
-
|
|
342
|
-
expect(mockGlob).toHaveBeenNthCalledWith(
|
|
343
|
-
2,
|
|
344
|
-
["**/*.js"],
|
|
345
|
-
expect.objectContaining({
|
|
346
|
-
ignore: ["node_modules/**", "*.test.js", "**/installer/**"],
|
|
347
|
-
}),
|
|
348
|
-
);
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
it("should not duplicate installer exclusion if already present", async () => {
|
|
352
|
-
const testCwd = process.cwd();
|
|
353
|
-
mockGlob.mockResolvedValueOnce([path.join(testCwd, "package.json")]);
|
|
354
|
-
mockGlob.mockResolvedValueOnce([path.join(testCwd, "src", "index.js")]);
|
|
355
|
-
|
|
356
|
-
appBundler.addGlobPattern("**/*.js", {
|
|
357
|
-
ignore: ["**/installer/**", "node_modules/**"],
|
|
358
|
-
});
|
|
359
|
-
await appBundler.bundle();
|
|
360
|
-
|
|
361
|
-
expect(mockGlob).toHaveBeenNthCalledWith(
|
|
362
|
-
2,
|
|
363
|
-
["**/*.js"],
|
|
364
|
-
expect.objectContaining({
|
|
365
|
-
ignore: ["**/installer/**", "node_modules/**", "**/installer/**"],
|
|
366
|
-
}),
|
|
367
|
-
);
|
|
368
|
-
// Note: The current implementation doesn't dedupe, which is acceptable
|
|
369
|
-
});
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
describe("package.json requirement", () => {
|
|
373
|
-
it("should include package.json by default", async () => {
|
|
374
|
-
const testCwd = process.cwd();
|
|
375
|
-
mockGlob.mockResolvedValueOnce([path.join(testCwd, "package.json")]);
|
|
376
|
-
|
|
377
|
-
const zip = await appBundler.bundle();
|
|
378
|
-
|
|
379
|
-
expect(mockGlob).toHaveBeenCalledWith(["package.json"], expect.any(Object));
|
|
380
|
-
|
|
381
|
-
const files = Object.keys(zip.files);
|
|
382
|
-
expect(files).toContain("package.json");
|
|
383
|
-
});
|
|
384
|
-
|
|
385
|
-
it("should not throw error when package.json is automatically included", async () => {
|
|
386
|
-
const testCwd = process.cwd();
|
|
387
|
-
// Set up files in mock filesystem first
|
|
388
|
-
vol.fromJSON({
|
|
389
|
-
[path.join(testCwd, "package.json")]: '{"name": "test"}',
|
|
390
|
-
[path.join(testCwd, "src", "index.js")]: "console.log('test');",
|
|
391
|
-
});
|
|
392
|
-
|
|
393
|
-
mockGlob.mockResolvedValueOnce([path.join(testCwd, "package.json")]);
|
|
394
|
-
mockGlob.mockResolvedValueOnce([path.join(testCwd, "src", "index.js")]);
|
|
395
|
-
|
|
396
|
-
appBundler.addGlobPattern("src/**/*.js");
|
|
397
|
-
|
|
398
|
-
await expect(appBundler.bundle()).resolves.toBeDefined();
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
it("should throw error if package.json is not found despite being added", async () => {
|
|
402
|
-
// Mock package.json pattern to return empty (simulating missing file)
|
|
403
|
-
mockGlob.mockResolvedValueOnce([]);
|
|
404
|
-
mockGlob.mockResolvedValueOnce([]);
|
|
405
|
-
|
|
406
|
-
appBundler.addGlobPattern("src/**/*.js");
|
|
407
|
-
|
|
408
|
-
await expect(appBundler.bundle()).rejects.toThrow("package.json not found");
|
|
409
|
-
});
|
|
410
|
-
});
|
|
411
|
-
|
|
412
|
-
describe("multiple patterns with installer exclusion", () => {
|
|
413
|
-
beforeEach(() => {
|
|
414
|
-
const testCwd = process.cwd();
|
|
415
|
-
vol.fromJSON({
|
|
416
|
-
[path.join(testCwd, "package.json")]: '{"name": "test-app"}',
|
|
417
|
-
[path.join(testCwd, "src", "index.js")]: "app code",
|
|
418
|
-
[path.join(testCwd, "assets", "logo.png")]: "image data",
|
|
419
|
-
[path.join(testCwd, "installer", "setup.exe")]: "installer",
|
|
420
|
-
});
|
|
421
|
-
});
|
|
422
|
-
|
|
423
|
-
it("should apply installer exclusion to all patterns", async () => {
|
|
424
|
-
const testCwd = process.cwd();
|
|
425
|
-
mockGlob.mockResolvedValueOnce([path.join(testCwd, "package.json")]);
|
|
426
|
-
mockGlob.mockResolvedValueOnce([path.join(testCwd, "src", "index.js")]);
|
|
427
|
-
mockGlob.mockResolvedValueOnce([path.join(testCwd, "assets", "logo.png")]);
|
|
428
|
-
|
|
429
|
-
appBundler.addGlobPattern("src/**/*.js", { ignore: "*.test.js" });
|
|
430
|
-
appBundler.addGlobPattern("assets/**/*");
|
|
431
|
-
|
|
432
|
-
const zip = await appBundler.bundle();
|
|
433
|
-
|
|
434
|
-
// Check that installer exclusion is applied to both patterns
|
|
435
|
-
expect(mockGlob).toHaveBeenNthCalledWith(
|
|
436
|
-
2,
|
|
437
|
-
["src/**/*.js"],
|
|
438
|
-
expect.objectContaining({
|
|
439
|
-
ignore: ["*.test.js", "**/installer/**"],
|
|
440
|
-
}),
|
|
441
|
-
);
|
|
442
|
-
expect(mockGlob).toHaveBeenNthCalledWith(
|
|
443
|
-
3,
|
|
444
|
-
["assets/**/*"],
|
|
445
|
-
expect.objectContaining({
|
|
446
|
-
ignore: "**/installer/**",
|
|
447
|
-
}),
|
|
448
|
-
);
|
|
449
|
-
|
|
450
|
-
const files = Object.keys(zip.files);
|
|
451
|
-
expect(files).toContain("package.json");
|
|
452
|
-
expect(files).toContain(path.join("src", "index.js"));
|
|
453
|
-
expect(files).toContain(path.join("assets", "logo.png"));
|
|
454
|
-
});
|
|
455
|
-
});
|
|
456
|
-
});
|
|
457
|
-
});
|
package/__tests__/temp.test.ts
DELETED
package/__tests__/utils.ts
DELETED
package/dist/chunk-RDQt0V5E.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
|
|
3
|
-
//#region rolldown:runtime
|
|
4
|
-
var __create = Object.create;
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __commonJS = (cb, mod) => function() {
|
|
11
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
15
|
-
key = keys[i];
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
-
get: ((k) => from[k]).bind(null, key),
|
|
18
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
return to;
|
|
22
|
-
};
|
|
23
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
-
value: mod,
|
|
25
|
-
enumerable: true
|
|
26
|
-
}) : target, mod));
|
|
27
|
-
var __toDynamicImportESM = (isNodeMode) => (mod) => __toESM(mod.default, isNodeMode);
|
|
28
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
29
|
-
|
|
30
|
-
//#endregion
|
|
31
|
-
export { __commonJS, __require, __toDynamicImportESM };
|