@b9g/shovel 0.2.0-beta.5 → 0.2.0-beta.6
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/bin/cli.js +18 -24
- package/package.json +3 -3
package/bin/cli.js
CHANGED
|
@@ -23,8 +23,8 @@ import * as Platform from "@b9g/platform";
|
|
|
23
23
|
|
|
24
24
|
// src/esbuild/watcher.ts
|
|
25
25
|
import * as ESBuild from "esbuild";
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
26
|
+
import { existsSync } from "fs";
|
|
27
|
+
import { resolve, join, dirname as dirname2 } from "path";
|
|
28
28
|
import { mkdir, unlink } from "fs/promises";
|
|
29
29
|
import { assetsPlugin } from "@b9g/assets/plugin";
|
|
30
30
|
|
|
@@ -80,15 +80,27 @@ function importMetaPlugin() {
|
|
|
80
80
|
// src/esbuild/watcher.ts
|
|
81
81
|
import { getLogger } from "@logtape/logtape";
|
|
82
82
|
var logger = getLogger(["watcher"]);
|
|
83
|
+
function findProjectRoot() {
|
|
84
|
+
let dir = process.cwd();
|
|
85
|
+
while (dir !== dirname2(dir)) {
|
|
86
|
+
if (existsSync(join(dir, "package.json"))) {
|
|
87
|
+
return dir;
|
|
88
|
+
}
|
|
89
|
+
dir = dirname2(dir);
|
|
90
|
+
}
|
|
91
|
+
return process.cwd();
|
|
92
|
+
}
|
|
83
93
|
var Watcher = class {
|
|
84
94
|
#options;
|
|
85
95
|
#ctx;
|
|
96
|
+
#projectRoot;
|
|
86
97
|
#initialBuildComplete;
|
|
87
98
|
#initialBuildResolve;
|
|
88
99
|
#currentEntrypoint;
|
|
89
100
|
#previousEntrypoint;
|
|
90
101
|
constructor(options) {
|
|
91
102
|
this.#options = options;
|
|
103
|
+
this.#projectRoot = findProjectRoot();
|
|
92
104
|
this.#initialBuildComplete = false;
|
|
93
105
|
this.#currentEntrypoint = "";
|
|
94
106
|
this.#previousEntrypoint = "";
|
|
@@ -98,9 +110,8 @@ var Watcher = class {
|
|
|
98
110
|
* @returns Result with success status and the hashed entrypoint path
|
|
99
111
|
*/
|
|
100
112
|
async start() {
|
|
101
|
-
const entryPath = resolve(this.#options.entrypoint);
|
|
102
|
-
const outputDir = resolve(this.#options.outDir);
|
|
103
|
-
const workspaceRoot = this.#findWorkspaceRoot();
|
|
113
|
+
const entryPath = resolve(this.#projectRoot, this.#options.entrypoint);
|
|
114
|
+
const outputDir = resolve(this.#projectRoot, this.#options.outDir);
|
|
104
115
|
await mkdir(join(outputDir, "server"), { recursive: true });
|
|
105
116
|
await mkdir(join(outputDir, "static"), { recursive: true });
|
|
106
117
|
const initialBuildPromise = new Promise((resolve3) => {
|
|
@@ -115,7 +126,7 @@ var Watcher = class {
|
|
|
115
126
|
outdir: `${outputDir}/server`,
|
|
116
127
|
entryNames: "[name]-[hash]",
|
|
117
128
|
metafile: true,
|
|
118
|
-
absWorkingDir:
|
|
129
|
+
absWorkingDir: this.#projectRoot,
|
|
119
130
|
plugins: [
|
|
120
131
|
importMetaPlugin(),
|
|
121
132
|
assetsPlugin({
|
|
@@ -137,7 +148,7 @@ var Watcher = class {
|
|
|
137
148
|
const outputs = Object.keys(result.metafile.outputs);
|
|
138
149
|
const jsOutput = outputs.find((p) => p.endsWith(".js"));
|
|
139
150
|
if (jsOutput) {
|
|
140
|
-
outputPath = resolve(jsOutput);
|
|
151
|
+
outputPath = resolve(this.#projectRoot, jsOutput);
|
|
141
152
|
}
|
|
142
153
|
}
|
|
143
154
|
if (success) {
|
|
@@ -187,23 +198,6 @@ var Watcher = class {
|
|
|
187
198
|
this.#ctx = void 0;
|
|
188
199
|
}
|
|
189
200
|
}
|
|
190
|
-
#findWorkspaceRoot() {
|
|
191
|
-
const initialCwd = process.cwd();
|
|
192
|
-
let workspaceRoot = initialCwd;
|
|
193
|
-
while (workspaceRoot !== dirname2(workspaceRoot)) {
|
|
194
|
-
try {
|
|
195
|
-
const packageJSON = JSON.parse(
|
|
196
|
-
readFileSync(resolve(workspaceRoot, "package.json"), "utf8")
|
|
197
|
-
);
|
|
198
|
-
if (packageJSON.workspaces) {
|
|
199
|
-
return workspaceRoot;
|
|
200
|
-
}
|
|
201
|
-
} catch {
|
|
202
|
-
}
|
|
203
|
-
workspaceRoot = dirname2(workspaceRoot);
|
|
204
|
-
}
|
|
205
|
-
return initialCwd;
|
|
206
|
-
}
|
|
207
201
|
};
|
|
208
202
|
|
|
209
203
|
// src/commands/develop.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@b9g/shovel",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.6",
|
|
4
4
|
"description": "ServiceWorker-first universal deployment platform. Write ServiceWorker apps once, deploy anywhere (Node/Bun/Cloudflare). Registry-based multi-app orchestration.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"source-map": "^0.7.4"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@b9g/assets": "^0.1.
|
|
24
|
+
"@b9g/assets": "^0.1.13",
|
|
25
25
|
"@b9g/cache": "^0.1.4",
|
|
26
26
|
"@b9g/crank": "^0.7.2",
|
|
27
27
|
"@b9g/filesystem": "^0.1.6",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@b9g/platform-bun": "^0.1.7",
|
|
32
32
|
"@b9g/platform-cloudflare": "^0.1.6",
|
|
33
33
|
"@b9g/platform-node": "^0.1.9",
|
|
34
|
-
"@b9g/router": "^0.1.
|
|
34
|
+
"@b9g/router": "^0.1.8",
|
|
35
35
|
"@types/bun": "^1.2.2",
|
|
36
36
|
"mitata": "^1.0.34",
|
|
37
37
|
"typescript": "^5.7.3"
|