@shopify/cli-hydrogen 2.0.7 → 2.0.10
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
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @shopify/cli-hydrogen
|
|
2
2
|
|
|
3
|
+
## 2.0.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a889b643: Add target flag for node preview command
|
|
8
|
+
- Updated dependencies [31b75488]
|
|
9
|
+
- @shopify/cli-kit@2.0.10
|
|
10
|
+
|
|
11
|
+
## 2.0.9
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [4170ac8e]
|
|
16
|
+
- Updated dependencies [4170ac8e]
|
|
17
|
+
- @shopify/cli-kit@2.0.9
|
|
18
|
+
|
|
19
|
+
## 2.0.8
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
- @shopify/cli-kit@2.0.8
|
|
25
|
+
|
|
3
26
|
## 2.0.7
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
|
@@ -1,8 +1,23 @@
|
|
|
1
|
-
import { error, file,
|
|
1
|
+
import { error, path, file, output, system, cli } from '@shopify/cli-kit';
|
|
2
2
|
import { fileURLToPath } from 'url';
|
|
3
3
|
import { Flags, Command } from '@oclif/core';
|
|
4
4
|
|
|
5
|
-
async function
|
|
5
|
+
async function previewInNode({ directory, port }) {
|
|
6
|
+
const buildOutputPath = await path.resolve(directory, "dist/node");
|
|
7
|
+
if (!await file.exists(buildOutputPath)) {
|
|
8
|
+
output.info(output.content`Couldn’t find a Node.js server build for this project. Running ${output.token.command("yarn shopify hydrogen build --target=node")} to create one.`);
|
|
9
|
+
await system.exec("yarn", ["shopify", "hydrogen", "build", "--target=node"], {
|
|
10
|
+
cwd: directory,
|
|
11
|
+
stdout: process.stdout
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
await system.exec("node", ["--enable-source-maps", buildOutputPath], {
|
|
15
|
+
env: { PORT: port },
|
|
16
|
+
cwd: directory,
|
|
17
|
+
stdout: process.stdout
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
async function previewInWorker({ directory, port }) {
|
|
6
21
|
const config = {
|
|
7
22
|
port,
|
|
8
23
|
workerFile: "dist/worker/index.js",
|
|
@@ -42,7 +57,11 @@ const _Preview = class extends Command {
|
|
|
42
57
|
const { flags } = await this.parse(_Preview);
|
|
43
58
|
const directory = flags.path ? path.resolve(flags.path) : process.cwd();
|
|
44
59
|
const port = parseInt(flags.port, 10);
|
|
45
|
-
|
|
60
|
+
if (flags.target === "worker") {
|
|
61
|
+
await previewInWorker({ directory, port });
|
|
62
|
+
} else if (flags.target === "node") {
|
|
63
|
+
await previewInNode({ directory, port });
|
|
64
|
+
}
|
|
46
65
|
}
|
|
47
66
|
};
|
|
48
67
|
let Preview = _Preview;
|
|
@@ -60,6 +79,13 @@ Preview.flags = {
|
|
|
60
79
|
description: "the port to run the preview server on",
|
|
61
80
|
default: "3000",
|
|
62
81
|
env: "SHOPIFY_FLAG_PORT"
|
|
82
|
+
}),
|
|
83
|
+
target: Flags.string({
|
|
84
|
+
char: "t",
|
|
85
|
+
description: "the target environment (worker or node)",
|
|
86
|
+
options: ["node", "worker"],
|
|
87
|
+
default: "worker",
|
|
88
|
+
env: "SHOPIFY_FLAG_PREVIEW_TARGET"
|
|
63
89
|
})
|
|
64
90
|
};
|
|
65
91
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview.js","sources":["../../../src/cli/services/preview.ts","../../../src/cli/commands/hydrogen/preview.ts"],"sourcesContent":["import {path, error, system, file} from '@shopify/cli-kit'\nimport {fileURLToPath} from 'url'\n\ninterface PreviewOptions {\n directory: string\n port: number\n}\n\
|
|
1
|
+
{"version":3,"file":"preview.js","sources":["../../../src/cli/services/preview.ts","../../../src/cli/commands/hydrogen/preview.ts"],"sourcesContent":["import {path, error, system, file, output} from '@shopify/cli-kit'\nimport {fileURLToPath} from 'url'\n\ninterface PreviewOptions {\n directory: string\n port: number\n}\n\nexport async function previewInNode({directory, port}: PreviewOptions) {\n const buildOutputPath = await path.resolve(directory, 'dist/node')\n\n if (!(await file.exists(buildOutputPath))) {\n output.info(\n output.content`Couldn’t find a Node.js server build for this project. Running ${output.token.command(\n 'yarn shopify hydrogen build --target=node',\n )} to create one.`,\n )\n\n await system.exec('yarn', ['shopify', 'hydrogen', 'build', '--target=node'], {\n cwd: directory,\n stdout: process.stdout,\n })\n }\n\n await system.exec('node', ['--enable-source-maps', buildOutputPath], {\n env: {PORT: port},\n cwd: directory,\n stdout: process.stdout,\n })\n}\n\nexport async function previewInWorker({directory, port}: PreviewOptions) {\n const config = {\n port,\n workerFile: 'dist/worker/index.js',\n assetsDir: 'dist/client',\n buildCommand: 'yarn build',\n modules: true,\n watch: true,\n buildWatchPaths: ['./src'],\n autoReload: true,\n }\n\n await file.write(path.resolve(directory, 'mini-oxygen.config.json'), JSON.stringify(config, null, 2))\n\n function cleanUp(options: {exit: boolean}) {\n if (options.exit) {\n file.remove(path.resolve(directory, 'mini-oxygen.config.json'))\n }\n }\n\n process.on('SIGINT', cleanUp.bind(null, {exit: true}))\n\n const executable = await oxygenPreviewExecutable()\n\n await system.exec(executable, [], {\n env: {NODE_OPTIONS: '--experimental-vm-modules'},\n cwd: directory,\n stdout: process.stdout,\n })\n}\n\nexport const OxygenPreviewExecutableNotFound = new error.Abort(\n 'Could not locate the executable file to run Oxygen locally.',\n)\n\nasync function oxygenPreviewExecutable(): Promise<string> {\n const cwd = path.dirname(fileURLToPath(import.meta.url))\n const executablePath = await path.findUp('node_modules/.bin/oxygen-preview', {type: 'file', cwd})\n if (!executablePath) {\n throw OxygenPreviewExecutableNotFound\n }\n return executablePath\n}\n","import {previewInWorker, previewInNode} from '../../services/preview'\nimport {path, cli} from '@shopify/cli-kit'\nimport {Command, Flags} from '@oclif/core'\n\nexport default class Preview extends Command {\n static description = 'Run a Hydrogen storefront locally in a worker environment'\n static flags = {\n ...cli.globalFlags,\n path: Flags.string({\n hidden: true,\n description: 'the path to your hydrogen storefront',\n env: 'SHOPIFY_FLAG_PATH',\n }),\n port: Flags.string({\n char: 'p',\n hidden: true,\n description: 'the port to run the preview server on',\n default: '3000',\n env: 'SHOPIFY_FLAG_PORT',\n }),\n target: Flags.string({\n char: 't',\n description: 'the target environment (worker or node)',\n options: ['node', 'worker'],\n default: 'worker',\n env: 'SHOPIFY_FLAG_PREVIEW_TARGET',\n }),\n }\n\n async run(): Promise<void> {\n const {flags} = await this.parse(Preview)\n const directory = flags.path ? path.resolve(flags.path) : process.cwd()\n const port = parseInt(flags.port, 10)\n\n if (flags.target === 'worker') {\n await previewInWorker({directory, port})\n } else if (flags.target === 'node') {\n await previewInNode({directory, port})\n }\n }\n}\n"],"names":[],"mappings":";;;;AAQoC,eAAA,aAAA,CAAA,EAAC,WAAW,IAAuB,EAAA,EAAA;AACrE,EAAA,MAAM,eAAkB,GAAA,MAAM,IAAK,CAAA,OAAA,CAAQ,WAAW,WAAW,CAAA,CAAA;AAEjE,EAAA,IAAI,CAAE,MAAM,IAAK,CAAA,MAAA,CAAO,eAAe,CAAI,EAAA;AACzC,IAAA,MAAA,CAAO,KACL,MAAO,CAAA,OAAA,CAAA,+DAAA,EAAyE,OAAO,KAAM,CAAA,OAAA,CAC3F,2CACF,CACF,CAAA,eAAA,CAAA,CAAA,CAAA;AAEA,IAAM,MAAA,MAAA,CAAO,KAAK,MAAQ,EAAA,CAAC,WAAW,UAAY,EAAA,OAAA,EAAS,eAAe,CAAG,EAAA;AAAA,MAC3E,GAAK,EAAA,SAAA;AAAA,MACL,QAAQ,OAAQ,CAAA,MAAA;AAAA,KACjB,CAAA,CAAA;AAAA,GACH;AAEA,EAAA,MAAM,OAAO,IAAK,CAAA,MAAA,EAAQ,CAAC,sBAAA,EAAwB,eAAe,C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AAA,2DAAA,CAAA;AADvB,QAES,KAAQ,GAAA;AAAA,EAAA,GACV,GAAI,CAAA,WAAA;AAAA,EACP,IAAA,EAAM,MAAM,MAAO,CAAA;AAAA,IACjB,MAAQ,EAAA,IAAA;AAAA,IACR,WAAa,EAAA,sCAAA;AAAA,IACb,GAAK,EAAA,mBAAA;AAAA,GACN,CAAA;AAAA,EACD,IAAA,EAAM,MAAM,MAAO,CAAA;AAAA,IACjB,IAAM,EAAA,GAAA;AAAA,IACN,MAAQ,EAAA,IAAA;AAAA,IACR,WAAa,EAAA,uCAAA;AAAA,IACb,OAAS,EAAA,MAAA;AAAA,IACT,GAAK,EAAA,mBAAA;AAAA,GACN,CAAA;AAAA,EACD,MAAA,EAAQ,MAAM,MAAO,CAAA;AAAA,IACnB,IAAM,EAAA,GAAA;AAAA,IACN,WAAa,EAAA,yCAAA;AAAA,IACb,OAAA,EAAS,CAAC,MAAA,EAAQ,QAAQ,CAAA;AAAA,IAC1B,OAAS,EAAA,QAAA;AAAA,IACT,GAAK,EAAA,6BAAA;AAAA,GACN,CAAA;AACH,CAAA;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopify/cli-hydrogen",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.10",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Commands for building Hydrogen storefronts",
|
|
6
6
|
"type": "module",
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
"vite": "^2.9.6"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@shopify/cli-kit": "2.0.
|
|
43
|
+
"@shopify/cli-kit": "2.0.10"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@babel/core": "^7.17.10",
|
|
47
47
|
"@shopify/ast-utilities": "^1.3.4",
|
|
48
|
-
"@shopify/cli-testing": "0.
|
|
48
|
+
"@shopify/cli-testing": "2.0.9",
|
|
49
49
|
"@shopify/prettier-config": "^1.1.2",
|
|
50
50
|
"@types/change-case": "^2.3.1",
|
|
51
51
|
"@types/connect": "^3.4.35",
|