@shopify/cli-hydrogen 0.30.2 → 0.33.1
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/commands/hydrogen/check.js +2 -6
- package/dist/commands/hydrogen/check.js.map +1 -1
- package/dist/commands/hydrogen/init.js +6 -13
- package/dist/commands/hydrogen/init.js.map +1 -1
- package/dist/commands/hydrogen/preview.js +42 -47
- package/dist/commands/hydrogen/preview.js.map +1 -1
- package/dist/{Command-bded1434.js → package-830cee27.js} +116 -13
- package/dist/package-830cee27.js.map +1 -0
- package/package.json +2 -2
- package/dist/Command-bded1434.js.map +0 -1
- package/dist/package-db1d6816.js +0 -105
- package/dist/package-db1d6816.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import 'prettier';
|
|
1
|
+
import { path, output, file, error } from '@shopify/cli-kit';
|
|
2
|
+
import { Flags, Command } from '@oclif/core';
|
|
4
3
|
import { Request, MiniflareCore, CorePlugin } from '@miniflare/core';
|
|
5
4
|
import { CachePlugin } from '@miniflare/cache';
|
|
6
5
|
import { VMScriptRunner } from '@miniflare/runner-vm';
|
|
7
6
|
import { Log, LogLevel } from '@miniflare/shared';
|
|
7
|
+
import require$$0$5 from 'path';
|
|
8
8
|
import require$$3 from 'http';
|
|
9
9
|
import require$$0$3 from 'fs';
|
|
10
10
|
import require$$7, { URL } from 'url';
|
|
@@ -13,20 +13,6 @@ import require$$0$2 from 'util';
|
|
|
13
13
|
import require$$4 from 'net';
|
|
14
14
|
import require$$0$4 from 'events';
|
|
15
15
|
import { MemoryStorage } from '@miniflare/storage-memory';
|
|
16
|
-
import '@oclif/core';
|
|
17
|
-
import 'constants';
|
|
18
|
-
import 'stream';
|
|
19
|
-
import 'assert';
|
|
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';
|
|
30
16
|
|
|
31
17
|
/**
|
|
32
18
|
* @param typeMap [Object] Map of MIME type -> Array[extensions]
|
|
@@ -3318,41 +3304,50 @@ 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.message(`
|
|
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
|
+
}),
|
|
3344
|
+
port: Flags.string({
|
|
3345
|
+
char: "p",
|
|
3346
|
+
hidden: true,
|
|
3347
|
+
description: "the port to run the preview server on",
|
|
3348
|
+
default: "3000"
|
|
3349
|
+
})
|
|
3354
3350
|
};
|
|
3355
|
-
Preview.args = [];
|
|
3356
3351
|
|
|
3357
3352
|
export { Preview as default };
|
|
3358
3353
|
//# sourceMappingURL=preview.js.map
|