@overlayed/cli 0.0.2 → 0.0.4
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 +5 -4
- package/package.json +7 -3
- 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/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 -18
- package/vitest.config.ts +0 -17
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{Builtins as e,Cli as t,Command as n,UsageError as r}from"clipanion";import i from"chalk";import a,{createReadStream as o}from"node:fs";import"arktype";import{createWriteStream as s,existsSync as c,mkdirSync as l,readdirSync as u,unlinkSync as d,writeFileSync as f}from"fs";import{join as p}from"path";import m from"node:path";import{glob as h}from"glob";import g,{fileURLToPath as _}from"node:url";import v from"jszip";const y={deployment:`deployment`};function b(e){return{all:e=e||new Map,on:function(t,n){var r=e.get(t);r?r.push(n):e.set(t,[n])},off:function(t,n){var r=e.get(t);r&&(n?r.splice(r.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var r=e.get(t);r&&r.slice().map(function(e){e(n)}),(r=e.get(`*`))&&r.slice().map(function(e){e(t,n)})}}}function x(e){return Object.prototype.toString.call(e)===`[object Object]`}function S(e){return e?Array.isArray(e)?e:[e]:[]}var C=class{data=[];constructor(){}get size(){return this.data.length}add(e){this.data.push(e)}next(){return this.data.shift()}clear(){this.data.length=0}*flush(){for(;this.size>0;){let e=this.next();e&&(yield e)}}},w=class{emitter;constructor(){this.emitter=b()}on(e,t){this.emitter.on(e,t)}off(e,t){this.emitter.off(e,t)}emit(e,t){this.emitter.emit(e,t)}removeAllListeners(){this.emitter.all.clear()}};function T(e,...t){let n=class extends e{static _instance;static getInstance(){return this._instance||(this._instance=new e(...t)),this._instance}static clearInstance(){this._instance=void 0}};return n}var E=class extends w{destroy(){this.removeAllListeners()}fatal(e,t,n){this.emit(`fatal`,{code:t,message:e,data:n,timestamp:Date.now()})}error(e,t,n){this.emit(`error`,{code:t,message:e,data:n,timestamp:Date.now()})}warn(e,t,n){this.emit(`warning`,{code:t,message:e,data:n,timestamp:Date.now()})}};T(E);var D=class e extends w{stream;logPath;baseFileName;currentDate;rotationCheckInterval;isRotating=!1;constructor(e,t){super(),this.logPath=e,this.baseFileName=t.replace(`.log`,``),this.currentDate=this.getDateString(new Date),this.ensureLogDirectory(),this.ensureLogFile(),this.stream=this.createStream(),this.rotationCheckInterval=this.startRotationCheck(),this.cleanupOldLogs()}static scope(t,n){return new e(t,n)}log(...e){this.write(`log`,...e)}error(...e){this.write(`error`,...e)}warn(...e){this.write(`warn`,...e)}info(...e){this.write(`info`,...e)}debug(...e){this.write(`debug`,...e)}async close(){clearInterval(this.rotationCheckInterval),await new Promise(e=>{this.stream.end(()=>e())})}getCurrentFileName(){return this.getFileName(this.currentDate)}getFileName(e){return`${this.baseFileName}-${e}.log`}ensureLogDirectory(){try{l(this.logPath,{recursive:!0})}catch(e){throw console.error(`Failed to create log directory ${this.logPath}:`,e),e}}ensureLogFile(){let e=p(this.logPath,this.getFileName(this.currentDate));if(!c(e))try{f(e,``,`utf8`)}catch(t){throw console.error(`Failed to create log file ${e}:`,t),t}}getDateString(e){return e.toISOString().split(`T`)[0]}createStream(){let e=p(this.logPath,this.getFileName(this.currentDate));return s(e,{flags:`a`,encoding:`utf8`})}async rotateLogs(){if(this.isRotating)return;this.isRotating=!0;let e=this.getDateString(new Date);e!==this.currentDate&&await new Promise(t=>{this.stream.end(()=>{this.currentDate=e,this.stream=this.createStream(),this.cleanupOldLogs(),t()})}),this.isRotating=!1}startRotationCheck(){return setInterval(()=>this.rotateLogs(),6e4)}cleanupOldLogs(){let e=u(this.logPath),t=new Date;t.setDate(t.getDate()-3),e.filter(e=>e.startsWith(this.baseFileName)&&e.endsWith(`.log`)).filter(e=>{let n=e.replace(`${this.baseFileName}-`,``).replace(`.log`,``),r=new Date(n);return r<t}).forEach(e=>{try{d(p(this.logPath,e))}catch(t){console.error(`Failed to delete old log file ${e}:`,t)}})}write(e,...t){let n=new Date,r=n.toISOString().replace(`T`,` `).replace(/\.\d+Z$/,``)+`.${n.getMilliseconds().toString().padStart(3,`0`)}`,i=t.map(e=>typeof e==`object`?JSON.stringify(e,void 0,2):String(e)).join(` `),a=`[${r}] [${e}] ${i}\n`;this.stream.write(a,e=>{e?this.emit(`error`,e):this.emit(`write`,a)})}};const O=()=>m.join(process.env.APPDATA??``,`overlayed`),k=e=>m.join(O(),`apps`,e),A=e=>m.join(k(e),`logs`);var j=class{fileLogger;path;appId;messageQueue=new C;fileName;constructor(e){this.fileName=e}init(e){this.appId=e,this.path=A(e),this.fileLogger=new D(this.path,this.fileName),this.messageQueue.flush().forEach(e=>{this.fileLogger?.[e.type](...e.args)})}scope(e){if(!this.appId||!this.path)throw Error(`Logger not initialized`);let t=`[${e}]`;return{scope:e=>this.scope(e),error:(...e)=>this.error(t,...e),warn:(...e)=>this.warn(t,...e),info:(...e)=>this.info(t,...e),log:(...e)=>this.log(t,...e)}}error(...e){this.handle(`error`,...e)}warn(...e){this.handle(`warn`,...e)}info(...e){this.handle(`log`,...e)}debug(...e){this.handle(`debug`,...e)}log(...e){this.handle(`log`,...e)}handle(e,...t){console[e](...t),this.fileLogger?this.fileLogger[e](...t):this.messageQueue.add({type:e,args:t})}};T(j,`main.log`);const M=`**/overlayed.config.{js,ts,mts}`;async function N(){let e=F(),t=await Promise.all(e.map(async e=>{let t=await import(g.pathToFileURL(e).toString());return t.default}));return t.filter(P)}function P(e){return x(e)&&`app`in e}function F(){let e=h.globSync(M,{absolute:!0,cwd:process.cwd()});return e}var I=class{pattern;options;constructor(e,t){this.pattern=e,this.options=t}},L=class{patterns=[];addGlobPattern(e,t){let n=this.resolveOptions(t),r=S(e);this.patterns.push(new I(r,n))}async bundle(){let e=new v;for(let t of this.patterns){let n=t.options??{},r;r=n.cwd?typeof n.cwd==`string`?n.cwd:_(n.cwd):process.cwd(),m.isAbsolute(r)||(r=m.resolve(r)),n.absolute=!0,n.cwd=r;let i=await h(t.pattern,n);await Promise.all(i.map(async t=>{let n=m.relative(r,t),i=o(t,`binary`);e.file(n,i,{compression:`DEFLATE`})}))}return e}resolveOptions(e){return e}},R=class extends L{installerFolderGlob=`**/installer/**`;constructor(){super(),this.addGlobPattern(`package.json`)}async bundle(){let e=await super.bundle(),t=e.file(`package.json`);if(!t)throw Error(`package.json not found`);return e}resolveOptions(e){if(!e)return{ignore:this.installerFolderGlob};let t=typeof e.ignore==`string`?[e.ignore]:e.ignore??[];return t.push(this.installerFolderGlob),e.ignore=t,e}},z=class extends n{overlayedConfigGlob=`**/overlayed.config.{js,ts,mts}`;static paths=[[`bundle`]];static usage=n.Usage({category:y.deployment,description:`Bundle the app and site for deployment.`,details:`
|
|
2
3
|
Bundle the app and site for deployment.
|
|
3
4
|
|
|
4
5
|
[Docs](http://docs.overlayed.gg/cli/bundle)
|
|
5
|
-
`,examples:[[`Basic usage`,`$0 bundle`]]});async execute(){let e=await this.resolveConfig(),t=
|
|
6
|
-
Multiple config files found matching ${
|
|
7
|
-
`));let
|
|
6
|
+
`,examples:[[`Basic usage`,`$0 bundle`]]});async execute(){let e=await this.resolveConfig(),t=a.createWriteStream(process.cwd()+`/app.zip`),n=await e.app.bundle();if(t.write(await n.generateAsync({type:`nodebuffer`})),e.site){let t=a.createWriteStream(process.cwd()+`/site.zip`),n=await e.site?.bundle();t.write(await n?.generateAsync({type:`nodebuffer`}))}this.context.stdout.write(i.green(`Bundle created successfully.`))}async resolveConfig(){let e=await N();if(e.length===0)throw new r(`No config file found matching `+this.overlayedConfigGlob);e.length>1&&this.context.stdout.write(i.yellow(`
|
|
7
|
+
Multiple config files found matching ${M}, using the first one.
|
|
8
|
+
`));let t=e.at(0);return{app:this.getAppBundler(t.app),site:t.site?this.getSiteBundler(t.site):void 0}}getAppBundler(e){let t=new R;return t.addGlobPattern(e.include,{ignore:e.exclude}),t}getSiteBundler(e){let t=new L;return t.addGlobPattern(e.include,{ignore:e.exclude}),t}};const B=process.argv.slice(2),V=new t({binaryName:`ogg`,binaryLabel:`Overlayed`});[z,e.HelpCommand].forEach(e=>{V.register(e)}),V.runExit(B);
|
package/package.json
CHANGED
|
@@ -9,23 +9,27 @@
|
|
|
9
9
|
"keywords": [
|
|
10
10
|
"typescript"
|
|
11
11
|
],
|
|
12
|
-
"version": "0.0.
|
|
12
|
+
"version": "0.0.4",
|
|
13
13
|
"description": "Overlayed CLI",
|
|
14
14
|
"packageManager": "pnpm@10.6.3",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"bin": {
|
|
17
|
-
"
|
|
17
|
+
"overlayed": "./dist/cli.js"
|
|
18
18
|
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist/**/*"
|
|
21
|
+
],
|
|
19
22
|
"devDependencies": {
|
|
20
23
|
"@ark/attest": "^0.45.0",
|
|
21
|
-
"@types/fs-extra": "^11.0.4",
|
|
22
24
|
"@overlayed/utils": "workspace:*",
|
|
23
25
|
"@overlayed/utils-node": "workspace:*",
|
|
26
|
+
"@types/fs-extra": "^11.0.4",
|
|
24
27
|
"tsdown": "^0.12.9",
|
|
25
28
|
"typescript": "^5.8.2",
|
|
26
29
|
"vitest": "^3.0.9"
|
|
27
30
|
},
|
|
28
31
|
"dependencies": {
|
|
32
|
+
"arktype": "^2.1.20",
|
|
29
33
|
"chalk": "^5.4.1",
|
|
30
34
|
"clipanion": "4.0.0-rc.4",
|
|
31
35
|
"fs-extra": "^11.3.0",
|
|
@@ -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/moon.yml
DELETED
package/setupVitest.ts
DELETED
package/src/bundle/command.ts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { Command, UsageError } from "clipanion";
|
|
2
|
-
import chalk from "chalk";
|
|
3
|
-
import fs from "node:fs";
|
|
4
|
-
import { COMMAND_CATEGORIES } from "../consts";
|
|
5
|
-
import {
|
|
6
|
-
type BundleAppConfig,
|
|
7
|
-
type BundleSiteConfig,
|
|
8
|
-
OVERLAYED_CONFIG_GLOB,
|
|
9
|
-
getOverlayedConfigs,
|
|
10
|
-
} from "@overlayed/utils-node";
|
|
11
|
-
import { AppBundler } from "./internal/appBundler";
|
|
12
|
-
import { Bundler } from "./internal/bundler";
|
|
13
|
-
|
|
14
|
-
export class BundleCommand extends Command {
|
|
15
|
-
private readonly overlayedConfigGlob = "**/overlayed.config.{js,ts,mts}";
|
|
16
|
-
|
|
17
|
-
public static override paths = [["bundle"]];
|
|
18
|
-
|
|
19
|
-
public static override usage = Command.Usage({
|
|
20
|
-
category: COMMAND_CATEGORIES.deployment,
|
|
21
|
-
description: "Bundle the app and site for deployment.",
|
|
22
|
-
details: `
|
|
23
|
-
Bundle the app and site for deployment.
|
|
24
|
-
|
|
25
|
-
[Docs](http://docs.overlayed.gg/cli/bundle)
|
|
26
|
-
`,
|
|
27
|
-
examples: [["Basic usage", "$0 bundle"]],
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
public async execute(): Promise<void> {
|
|
31
|
-
const config = await this.resolveConfig();
|
|
32
|
-
|
|
33
|
-
// TODO remove this and send via API instead
|
|
34
|
-
const appWriteStream = fs.createWriteStream(process.cwd() + "/app.zip");
|
|
35
|
-
const appZip = await config.app.bundle();
|
|
36
|
-
appWriteStream.write(await appZip.generateAsync({ type: "nodebuffer" }));
|
|
37
|
-
|
|
38
|
-
if (config.site) {
|
|
39
|
-
const siteWriteStream = fs.createWriteStream(process.cwd() + "/site.zip");
|
|
40
|
-
const siteZip = await config.site?.bundle();
|
|
41
|
-
|
|
42
|
-
siteWriteStream.write(await siteZip?.generateAsync({ type: "nodebuffer" }));
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
this.context.stdout.write(chalk.green("Bundle created successfully."));
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
private async resolveConfig() {
|
|
49
|
-
const configs = await getOverlayedConfigs();
|
|
50
|
-
|
|
51
|
-
if (configs.length === 0) {
|
|
52
|
-
throw new UsageError("No config file found matching " + this.overlayedConfigGlob);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (configs.length > 1) {
|
|
56
|
-
this.context.stdout.write(
|
|
57
|
-
chalk.yellow(`
|
|
58
|
-
Multiple config files found matching ${OVERLAYED_CONFIG_GLOB}, using the first one.
|
|
59
|
-
`),
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const config = configs.at(0)!;
|
|
64
|
-
return {
|
|
65
|
-
app: this.getAppBundler(config.app),
|
|
66
|
-
site: config.site ? this.getSiteBundler(config.site) : undefined,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
private getAppBundler(config: BundleAppConfig) {
|
|
71
|
-
const bundler = new AppBundler();
|
|
72
|
-
bundler.addGlobPattern(config.include, {
|
|
73
|
-
ignore: config.exclude,
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
return bundler;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
private getSiteBundler(config: BundleSiteConfig) {
|
|
80
|
-
const bundler = new Bundler();
|
|
81
|
-
bundler.addGlobPattern(config.include, {
|
|
82
|
-
ignore: config.exclude,
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
return bundler;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Bundler, type BundlerPatternOptions } from "./bundler";
|
|
2
|
-
import type Zip from "jszip";
|
|
3
|
-
|
|
4
|
-
export class AppBundler extends Bundler {
|
|
5
|
-
private readonly installerFolderGlob = "**/installer/**";
|
|
6
|
-
|
|
7
|
-
public constructor() {
|
|
8
|
-
super();
|
|
9
|
-
this.addGlobPattern("package.json");
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
public override async bundle(): Promise<Zip> {
|
|
13
|
-
const zip = await super.bundle();
|
|
14
|
-
|
|
15
|
-
const packageJson = zip.file("package.json");
|
|
16
|
-
if (!packageJson) {
|
|
17
|
-
throw new Error("package.json not found");
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return zip;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
protected override resolveOptions(options: BundlerPatternOptions | undefined): BundlerPatternOptions | undefined {
|
|
24
|
-
if (!options) {
|
|
25
|
-
return {
|
|
26
|
-
ignore: this.installerFolderGlob,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const ignore = typeof options.ignore === "string" ? [options.ignore] : (options.ignore ?? []);
|
|
31
|
-
ignore.push(this.installerFolderGlob);
|
|
32
|
-
options.ignore = ignore;
|
|
33
|
-
return options;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { glob, type GlobOptionsWithFileTypesFalse } from "glob";
|
|
2
|
-
import { createReadStream } from "node:fs";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import Zip from "jszip";
|
|
6
|
-
import { asArray } from "@overlayed/utils";
|
|
7
|
-
|
|
8
|
-
class PatternSet {
|
|
9
|
-
public readonly pattern: string[];
|
|
10
|
-
public readonly options?: GlobOptionsWithFileTypesFalse;
|
|
11
|
-
|
|
12
|
-
constructor(pattern: string[], options?: BundlerPatternOptions) {
|
|
13
|
-
this.pattern = pattern;
|
|
14
|
-
this.options = options;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface BundlerPatternOptions extends GlobOptionsWithFileTypesFalse {
|
|
19
|
-
ignore?: string | string[];
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Bundles files into a zip file based on a set of glob patterns.
|
|
24
|
-
*
|
|
25
|
-
* Always includes package.json in the bundle.
|
|
26
|
-
* Excludes installer folder.
|
|
27
|
-
*/
|
|
28
|
-
export class Bundler {
|
|
29
|
-
private patterns: PatternSet[] = [];
|
|
30
|
-
|
|
31
|
-
public addGlobPattern(pattern: string | string[], options?: BundlerPatternOptions): void {
|
|
32
|
-
const resolvedOptions = this.resolveOptions(options);
|
|
33
|
-
const patternArray = asArray(pattern);
|
|
34
|
-
this.patterns.push(new PatternSet(patternArray, resolvedOptions));
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
public async bundle(): Promise<Zip> {
|
|
38
|
-
const zip = new Zip();
|
|
39
|
-
|
|
40
|
-
for (const pattern of this.patterns) {
|
|
41
|
-
const options = pattern.options ?? {};
|
|
42
|
-
|
|
43
|
-
let cwd: string;
|
|
44
|
-
|
|
45
|
-
if (!options.cwd) {
|
|
46
|
-
cwd = process.cwd();
|
|
47
|
-
} else if (typeof options.cwd === "string") {
|
|
48
|
-
cwd = options.cwd;
|
|
49
|
-
} else {
|
|
50
|
-
cwd = fileURLToPath(options.cwd);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (!path.isAbsolute(cwd)) {
|
|
54
|
-
cwd = path.resolve(cwd);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
options.absolute = true;
|
|
58
|
-
options.cwd = cwd;
|
|
59
|
-
|
|
60
|
-
const files = await glob(pattern.pattern, options);
|
|
61
|
-
await Promise.all(
|
|
62
|
-
files.map(async (file) => {
|
|
63
|
-
const zipPath = path.relative(cwd, file);
|
|
64
|
-
const stream = createReadStream(file, "binary");
|
|
65
|
-
|
|
66
|
-
zip.file(zipPath, stream, { compression: "DEFLATE" });
|
|
67
|
-
}),
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return zip;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
protected resolveOptions(options: BundlerPatternOptions | undefined): BundlerPatternOptions | undefined {
|
|
75
|
-
return options;
|
|
76
|
-
}
|
|
77
|
-
}
|
package/src/cli.ts
DELETED
package/src/consts.ts
DELETED
package/temp/myfile.txt
DELETED
|
File without changes
|
package/temp/overlayed.config.ts
DELETED
package/temp/someotherfile.ts
DELETED
|
File without changes
|
package/tsconfig.build.json
DELETED
package/tsconfig.json
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.options.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"emitDeclarationOnly": true,
|
|
5
|
-
"outDir": "./dist",
|
|
6
|
-
"paths": {
|
|
7
|
-
"@overlayed/utils": [
|
|
8
|
-
"../utils/src/index.ts"
|
|
9
|
-
],
|
|
10
|
-
"@overlayed/utils/*": [
|
|
11
|
-
"../utils/src/*"
|
|
12
|
-
],
|
|
13
|
-
"@overlayed/utils-node": [
|
|
14
|
-
"../utils-node/src/index.ts"
|
|
15
|
-
],
|
|
16
|
-
"@overlayed/utils-node/*": [
|
|
17
|
-
"../utils-node/src/*"
|
|
18
|
-
]
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
"include": [
|
|
22
|
-
"*.js",
|
|
23
|
-
"*.ts",
|
|
24
|
-
"__tests__/**/*",
|
|
25
|
-
"src/**/*"
|
|
26
|
-
],
|
|
27
|
-
"references": [
|
|
28
|
-
{
|
|
29
|
-
"path": "./tsconfig.build.json"
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
"path": "../utils"
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
"path": "../utils-node"
|
|
36
|
-
}
|
|
37
|
-
]
|
|
38
|
-
}
|
package/tsdown.config.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "tsdown";
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
tsconfig: "tsconfig.build.json",
|
|
5
|
-
platform: "node",
|
|
6
|
-
entry: {
|
|
7
|
-
cli: "src/cli.ts",
|
|
8
|
-
},
|
|
9
|
-
dts: {
|
|
10
|
-
sourcemap: false,
|
|
11
|
-
resolve: true,
|
|
12
|
-
},
|
|
13
|
-
minify: true,
|
|
14
|
-
sourcemap: false,
|
|
15
|
-
// TODO: investigate why treeshaking is not working, maybe a bug with tsdown since its still a newer package
|
|
16
|
-
// for now we can at least remove arktype since its huge
|
|
17
|
-
external: [/arktype/, /@ark\/util/],
|
|
18
|
-
});
|
package/vitest.config.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "vitest/config";
|
|
2
|
-
import tsconfigPaths from "vite-tsconfig-paths";
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
plugins: [tsconfigPaths({
|
|
5
|
-
skip(dir) {
|
|
6
|
-
return !dir.includes("templates");
|
|
7
|
-
},
|
|
8
|
-
}),],
|
|
9
|
-
test: {
|
|
10
|
-
globalSetup: "./setupVitest.ts",
|
|
11
|
-
typecheck: {
|
|
12
|
-
enabled: true,
|
|
13
|
-
ignoreSourceErrors: true,
|
|
14
|
-
tsconfig: "./tsconfig.build.json",
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
});
|