@shopify/cli-hydrogen 0.31.0 → 0.33.2
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 +23 -0
- package/dist/{Command-bded1434.js → Command-fd93d525.js} +55786 -55670
- package/dist/Command-fd93d525.js.map +1 -0
- package/dist/commands/hydrogen/check.js +12 -16
- package/dist/commands/hydrogen/check.js.map +1 -1
- package/dist/commands/hydrogen/init.js +137 -138
- package/dist/commands/hydrogen/init.js.map +1 -1
- package/dist/commands/hydrogen/preview.js +54 -57
- package/dist/commands/hydrogen/preview.js.map +1 -1
- package/package.json +19 -8
- package/dist/Command-bded1434.js.map +0 -1
- package/dist/package-fa31d133.js +0 -105
- package/dist/package-fa31d133.js.map +0 -1
|
@@ -1,32 +1,18 @@
|
|
|
1
|
-
import require$$0$5, { resolve } from 'path';
|
|
2
|
-
import { C as Command, H as HelpfulError } from '../../Command-bded1434.js';
|
|
3
|
-
import 'prettier';
|
|
4
1
|
import { Request, MiniflareCore, CorePlugin } from '@miniflare/core';
|
|
5
|
-
import { CachePlugin } from '@miniflare/cache';
|
|
6
|
-
import { VMScriptRunner } from '@miniflare/runner-vm';
|
|
7
|
-
import { Log, LogLevel } from '@miniflare/shared';
|
|
8
|
-
import require$$3 from 'http';
|
|
9
|
-
import require$$0$3 from 'fs';
|
|
10
|
-
import require$$7, { URL } from 'url';
|
|
11
2
|
import require$$0$1 from 'tty';
|
|
12
3
|
import require$$0$2 from 'util';
|
|
4
|
+
import require$$0$3 from 'fs';
|
|
13
5
|
import require$$4 from 'net';
|
|
14
6
|
import require$$0$4 from 'events';
|
|
7
|
+
import require$$7 from 'url';
|
|
8
|
+
import require$$3 from 'http';
|
|
9
|
+
import { path, output, file, error } from '@shopify/cli-kit';
|
|
10
|
+
import { URL } from 'node:url';
|
|
15
11
|
import { MemoryStorage } from '@miniflare/storage-memory';
|
|
16
|
-
import '@
|
|
17
|
-
import '
|
|
18
|
-
import '
|
|
19
|
-
import '
|
|
20
|
-
import 'os';
|
|
21
|
-
import 'readline';
|
|
22
|
-
import 'buffer';
|
|
23
|
-
import 'child_process';
|
|
24
|
-
import 'string_decoder';
|
|
25
|
-
import 'crypto';
|
|
26
|
-
import '@shopify/cli-kit';
|
|
27
|
-
import 'module';
|
|
28
|
-
import 'vm';
|
|
29
|
-
import 'v8';
|
|
12
|
+
import { CachePlugin } from '@miniflare/cache';
|
|
13
|
+
import { VMScriptRunner } from '@miniflare/runner-vm';
|
|
14
|
+
import { Log, LogLevel } from '@miniflare/shared';
|
|
15
|
+
import { Flags, Command } from '@oclif/core';
|
|
30
16
|
|
|
31
17
|
/**
|
|
32
18
|
* @param typeMap [Object] Map of MIME type -> Array[extensions]
|
|
@@ -3230,7 +3216,7 @@ function getProtohost(url) {
|
|
|
3230
3216
|
|
|
3231
3217
|
function createAssetMiddleware(assets) {
|
|
3232
3218
|
return (req, res, next) => {
|
|
3233
|
-
const filePath =
|
|
3219
|
+
const filePath = path.join(process.cwd(), "./dist/client", req.url);
|
|
3234
3220
|
if (assets.includes(filePath)) {
|
|
3235
3221
|
const rs = require$$0$3.createReadStream(filePath);
|
|
3236
3222
|
const { size } = require$$0$3.statSync(filePath);
|
|
@@ -3238,7 +3224,7 @@ function createAssetMiddleware(assets) {
|
|
|
3238
3224
|
res.setHeader("Content-Length", size);
|
|
3239
3225
|
return rs.pipe(res);
|
|
3240
3226
|
}
|
|
3241
|
-
next();
|
|
3227
|
+
return next();
|
|
3242
3228
|
};
|
|
3243
3229
|
}
|
|
3244
3230
|
function createRequestMiddleware(mf) {
|
|
@@ -3261,9 +3247,9 @@ function createRequestMiddleware(mf) {
|
|
|
3261
3247
|
}
|
|
3262
3248
|
}
|
|
3263
3249
|
res.end();
|
|
3264
|
-
} catch (
|
|
3250
|
+
} catch (error) {
|
|
3265
3251
|
res.writeHead(500, { "Content-Type": "text/plain; charset=UTF-8" });
|
|
3266
|
-
res.end(
|
|
3252
|
+
res.end(error.stack, "utf8");
|
|
3267
3253
|
}
|
|
3268
3254
|
return response;
|
|
3269
3255
|
};
|
|
@@ -3318,41 +3304,52 @@ const PLUGINS = {
|
|
|
3318
3304
|
CachePlugin
|
|
3319
3305
|
};
|
|
3320
3306
|
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
});
|
|
3336
|
-
const mf = new MiniOxygen({
|
|
3337
|
-
buildCommand: "yarn build",
|
|
3338
|
-
globals: { Oxygen: {} },
|
|
3339
|
-
scriptPath: resolve(this.root, "dist/worker/worker.js"),
|
|
3340
|
-
sitePath: resolve(this.root, "dist/client")
|
|
3341
|
-
});
|
|
3342
|
-
const app = await mf.createServer({ assets: files });
|
|
3343
|
-
app.listen(port, () => {
|
|
3344
|
-
this.interface.say(`
|
|
3307
|
+
async function preview({ directory, port }) {
|
|
3308
|
+
await runPreview({ directory, port });
|
|
3309
|
+
}
|
|
3310
|
+
async function runPreview({ directory, port }) {
|
|
3311
|
+
const files = await path.glob("dist/client/**/*");
|
|
3312
|
+
const mf = new MiniOxygen({
|
|
3313
|
+
buildCommand: "yarn build",
|
|
3314
|
+
globals: { Oxygen: {} },
|
|
3315
|
+
scriptPath: path.resolve(directory, "dist/worker/index.js"),
|
|
3316
|
+
sitePath: path.resolve(directory, "dist/client")
|
|
3317
|
+
});
|
|
3318
|
+
const app = await mf.createServer({ assets: files });
|
|
3319
|
+
app.listen(port, () => {
|
|
3320
|
+
output.info(`
|
|
3345
3321
|
Started miniOxygen server. Listening at http://localhost:${port}
|
|
3346
3322
|
`);
|
|
3347
|
-
|
|
3348
|
-
}
|
|
3323
|
+
});
|
|
3349
3324
|
}
|
|
3350
|
-
|
|
3351
|
-
|
|
3325
|
+
|
|
3326
|
+
const _Preview = class extends Command {
|
|
3327
|
+
async run() {
|
|
3328
|
+
const { flags } = await this.parse(_Preview);
|
|
3329
|
+
const directory = flags.path ? path.resolve(flags.path) : process.cwd();
|
|
3330
|
+
const port = parseInt(flags.port, 10);
|
|
3331
|
+
if (!await file.exists(path.resolve(directory, "dist/worker"))) {
|
|
3332
|
+
throw new error.Abort(`Couldn't find worker build. Run "yarn build" in ${directory}, and try again.`);
|
|
3333
|
+
}
|
|
3334
|
+
await preview({ directory, port });
|
|
3335
|
+
}
|
|
3336
|
+
};
|
|
3337
|
+
let Preview = _Preview;
|
|
3338
|
+
Preview.description = "Run a Hydrogen storefront locally in a worker environment";
|
|
3352
3339
|
Preview.flags = {
|
|
3353
|
-
|
|
3340
|
+
path: Flags.string({
|
|
3341
|
+
hidden: true,
|
|
3342
|
+
description: "the path to your hydrogen storefront",
|
|
3343
|
+
env: "SHOPIFY_FLAG_PATH"
|
|
3344
|
+
}),
|
|
3345
|
+
port: Flags.string({
|
|
3346
|
+
char: "p",
|
|
3347
|
+
hidden: true,
|
|
3348
|
+
description: "the port to run the preview server on",
|
|
3349
|
+
default: "3000",
|
|
3350
|
+
env: "SHOPIFY_FLAG_PORT"
|
|
3351
|
+
})
|
|
3354
3352
|
};
|
|
3355
|
-
Preview.args = [];
|
|
3356
3353
|
|
|
3357
3354
|
export { Preview as default };
|
|
3358
3355
|
//# sourceMappingURL=preview.js.map
|