@shopify/cli-hydrogen 3.33.0 → 3.35.0
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/commands/hydrogen/add/eslint.js +3 -2
- package/dist/cli/commands/hydrogen/add/eslint.js.map +1 -1
- package/dist/cli/commands/hydrogen/add/tailwind.js +3 -2
- package/dist/cli/commands/hydrogen/add/tailwind.js.map +1 -1
- package/dist/cli/commands/hydrogen/build.js +4 -3
- package/dist/cli/commands/hydrogen/build.js.map +1 -1
- package/dist/cli/commands/hydrogen/deploy.js +6 -4
- package/dist/cli/commands/hydrogen/deploy.js.map +1 -1
- package/dist/cli/commands/hydrogen/dev.js +4 -3
- package/dist/cli/commands/hydrogen/dev.js.map +1 -1
- package/dist/cli/commands/hydrogen/info.js +4 -3
- package/dist/cli/commands/hydrogen/info.js.map +1 -1
- package/dist/cli/commands/hydrogen/preview.js +4 -3
- package/dist/cli/commands/hydrogen/preview.js.map +1 -1
- package/dist/cli/models/hydrogen.js +6 -5
- package/dist/cli/models/hydrogen.js.map +1 -1
- package/dist/cli/services/build/check-lockfile.js +5 -3
- package/dist/cli/services/build/check-lockfile.js.map +1 -1
- package/dist/cli/services/build.js +3 -2
- package/dist/cli/services/build.js.map +1 -1
- package/dist/cli/services/deploy/config.js +16 -12
- package/dist/cli/services/deploy/config.js.map +1 -1
- package/dist/cli/services/deploy/upload.js +4 -3
- package/dist/cli/services/deploy/upload.js.map +1 -1
- package/dist/cli/services/deploy.js +8 -7
- package/dist/cli/services/deploy.js.map +1 -1
- package/dist/cli/services/dev/check-version.js +2 -2
- package/dist/cli/services/dev/check-version.js.map +1 -1
- package/dist/cli/services/eslint.js +8 -6
- package/dist/cli/services/eslint.js.map +1 -1
- package/dist/cli/services/preview.js +9 -7
- package/dist/cli/services/preview.js.map +1 -1
- package/dist/cli/services/tailwind.js +14 -12
- package/dist/cli/services/tailwind.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { createDeployment, healthCheck, uploadDeployment } from './deploy/upload.js';
|
|
2
2
|
import { buildTaskList } from './build.js';
|
|
3
3
|
import { validateProject, fillDeployConfig } from './deploy/config.js';
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import { ui } from '@shopify/cli-kit';
|
|
5
|
+
import { sleep } from '@shopify/cli-kit/node/system';
|
|
6
|
+
import { isUnitTest } from '@shopify/cli-kit/node/environment/local';
|
|
6
7
|
const backoffPolicy = [5, 10, 15, 30, 60];
|
|
7
8
|
export async function deployToOxygen(_config) {
|
|
8
9
|
await validateProject(_config);
|
|
@@ -65,8 +66,8 @@ export async function deployToOxygen(_config) {
|
|
|
65
66
|
"The deployment uploaded but hasn't become reachable within 2 minutes. Check the preview URL to see if deployment succeeded. If it didn't, then try again later.";
|
|
66
67
|
return;
|
|
67
68
|
}
|
|
68
|
-
if (retryCount && !isUnitTest)
|
|
69
|
-
await
|
|
69
|
+
if (retryCount && !isUnitTest())
|
|
70
|
+
await sleep(backoffPolicy[retryCount - 1]);
|
|
70
71
|
await healthCheck(ctx.previewURL);
|
|
71
72
|
task.title = '✅ Deployed successfully';
|
|
72
73
|
},
|
|
@@ -78,7 +79,7 @@ export async function deployToOxygen(_config) {
|
|
|
78
79
|
const list = ui.newListr(tasks, {
|
|
79
80
|
concurrent: false,
|
|
80
81
|
rendererOptions: { collapse: false },
|
|
81
|
-
rendererSilent: isUnitTest,
|
|
82
|
+
rendererSilent: isUnitTest(),
|
|
82
83
|
});
|
|
83
84
|
return list.run();
|
|
84
85
|
}
|
|
@@ -97,7 +98,7 @@ task, errorMessage) {
|
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
|
-
if (retryCount && !isUnitTest)
|
|
101
|
-
await
|
|
101
|
+
if (retryCount && !isUnitTest())
|
|
102
|
+
await sleep(backoffPolicy[retryCount - 1]);
|
|
102
103
|
}
|
|
103
104
|
//# sourceMappingURL=deploy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../../src/cli/services/deploy.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,gBAAgB,EAAE,WAAW,EAAE,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AAClF,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAA;AACxC,OAAO,EAAC,eAAe,EAAE,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AACpE,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../../src/cli/services/deploy.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,gBAAgB,EAAE,WAAW,EAAE,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AAClF,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAA;AACxC,OAAO,EAAC,eAAe,EAAE,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AACpE,OAAO,EAAC,EAAE,EAAC,MAAM,kBAAkB,CAAA;AACnC,OAAO,EAAC,KAAK,EAAC,MAAM,8BAA8B,CAAA;AAClD,OAAO,EAAC,UAAU,EAAC,MAAM,yCAAyC,CAAA;AASlE,MAAM,aAAa,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;AAEzC,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAAqB;IACxD,MAAM,eAAe,CAAC,OAAO,CAAC,CAAA;IAE9B,2CAA2C;IAC3C,MAAM,KAAK,GAAgC;QACzC;YACE,KAAK,EAAE,8BAA8B;YACrC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;gBACxB,GAAG,CAAC,MAAM,GAAG,MAAM,gBAAgB,CAAC,OAAO,CAAC,CAAA;gBAC5C,IAAI,CAAC,KAAK,GAAG,6BAA6B,CAAA;YAC5C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EAAE,KAAK,CAAA;IAC3C,IAAI,UAAU,KAAK,aAAa,CAAC,MAAM,EAAE;QACvC,MAAM,IAAI,KAAK,CAAC,GAAG,YAAY,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAA;KACnF;IACD,IAAI,UAAU,EAAE;QACd,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YAC1B,MAAM,kBAAkB,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAA;YAC/F,IAAI,kBAAkB,EAAE;gBACtB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAA;aAC5C;SACF;KACF;IACD,IAAI,UAAU,IAAI,CAAC,UAAU,EAAE;QAAE,MAAM,KAAK,CAAC,aAAa,CAAC,UAAU,GAAG,CAAC,CAAE,CAAC,CAAA;AAC9E,CAAC","sourcesContent":["import {DeployConfig, ReqDeployConfig} from './deploy/types.js'\nimport {createDeployment, healthCheck, uploadDeployment} from './deploy/upload.js'\nimport {buildTaskList} from './build.js'\nimport {validateProject, fillDeployConfig} from './deploy/config.js'\nimport {ui} from '@shopify/cli-kit'\nimport {sleep} from '@shopify/cli-kit/node/system'\nimport {isUnitTest} from '@shopify/cli-kit/node/environment/local'\n\ninterface TaskContext {\n config: ReqDeployConfig\n deploymentID: string\n assetBaseURL: string\n previewURL: string\n}\n\nconst backoffPolicy = [5, 10, 15, 30, 60]\n\nexport async function deployToOxygen(_config: DeployConfig) {\n await validateProject(_config)\n\n /* eslint-disable require-atomic-updates */\n const tasks: ui.ListrTask<TaskContext>[] = [\n {\n title: '📝 Getting deployment config',\n task: async (ctx, task) => {\n ctx.config = await fillDeployConfig(_config)\n task.title = '📝 Deployment config parsed'\n },\n },\n {\n title: '💡 Initializing deployment',\n task: async (ctx, task) => {\n await shouldRetryOxygenCall(task, 'Could not create deployment on Oxygen.')\n\n const {deploymentID, assetBaseURL} = await createDeployment(ctx.config)\n ctx.assetBaseURL = assetBaseURL\n ctx.deploymentID = deploymentID\n task.title = '✨ Deployment initialized'\n },\n retry: backoffPolicy.length,\n },\n {\n title: '🛠 Building project',\n task: async (ctx, task) => {\n const subTasks = buildTaskList({\n directory: ctx.config.path,\n targets: {\n client: true,\n worker: '@shopify/hydrogen/platforms/worker',\n node: false,\n },\n assetBaseURL: ctx.assetBaseURL,\n })\n\n return task.newListr(subTasks)\n },\n skip: (ctx) => ctx.config.pathToBuild,\n },\n {\n title: '🚀 Uploading deployment files',\n task: async (ctx, task) => {\n await shouldRetryOxygenCall(task, 'Uploading files to Oxygen failed.')\n\n ctx.previewURL = await uploadDeployment(ctx.config, ctx.deploymentID)\n task.output = `Preview URL: ${ctx.previewURL}`\n task.title = '🚀 Files uploaded'\n },\n options: {\n bottomBar: Infinity,\n persistentOutput: true,\n },\n retry: backoffPolicy.length,\n },\n {\n title: '📡 Checking deployment health',\n task: async (ctx, task) => {\n const retryCount = task.isRetrying()?.count\n\n if (retryCount === backoffPolicy.length) {\n task.title =\n \"The deployment uploaded but hasn't become reachable within 2 minutes. Check the preview URL to see if deployment succeeded. If it didn't, then try again later.\"\n return\n }\n if (retryCount && !isUnitTest()) await sleep(backoffPolicy[retryCount - 1]!)\n\n await healthCheck(ctx.previewURL)\n task.title = '✅ Deployed successfully'\n },\n retry: backoffPolicy.length,\n skip: (ctx) => !ctx.config.healthCheck,\n },\n ]\n /* eslint-enable require-atomic-updates */\n\n const list = ui.newListr(tasks, {\n concurrent: false,\n rendererOptions: {collapse: false},\n rendererSilent: isUnitTest(),\n })\n\n return list.run()\n}\n\nasync function shouldRetryOxygenCall(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n task: ui.ListrTaskWrapper<TaskContext, any>,\n errorMessage: string,\n) {\n const retryCount = task.isRetrying()?.count\n if (retryCount === backoffPolicy.length) {\n throw new Error(`${errorMessage} ${task.errors[task.errors.length - 1]?.message}`)\n }\n if (retryCount) {\n if (task.errors.length > 0) {\n const unrecoverableError = task.errors.find((error) => error.message.includes('Unrecoverable'))\n if (unrecoverableError) {\n throw new Error(unrecoverableError.message)\n }\n }\n }\n if (retryCount && !isUnitTest()) await sleep(backoffPolicy[retryCount - 1]!)\n}\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { system } from '@shopify/cli-kit';
|
|
2
1
|
import { checkForNewVersion } from '@shopify/cli-kit/node/node-package-manager';
|
|
2
|
+
import { captureOutput } from '@shopify/cli-kit/node/system';
|
|
3
3
|
import { renderInfo } from '@shopify/cli-kit/node/ui';
|
|
4
4
|
const PACKAGE_NAME = '@shopify/hydrogen';
|
|
5
5
|
export async function checkHydrogenVersion(directory) {
|
|
6
|
-
const currentVersion = await
|
|
6
|
+
const currentVersion = await captureOutput('node', ['-p', `require('./node_modules/${PACKAGE_NAME}/package.json').version`], {
|
|
7
7
|
cwd: directory,
|
|
8
8
|
});
|
|
9
9
|
if (!currentVersion) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-version.js","sourceRoot":"","sources":["../../../../src/cli/services/dev/check-version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"check-version.js","sourceRoot":"","sources":["../../../../src/cli/services/dev/check-version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,4CAA4C,CAAA;AAC7E,OAAO,EAAC,aAAa,EAAC,MAAM,8BAA8B,CAAA;AAC1D,OAAO,EAAC,UAAU,EAAC,MAAM,0BAA0B,CAAA;AAEnD,MAAM,YAAY,GAAG,mBAAmB,CAAA;AAExC,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,SAAiB;IAC1D,MAAM,cAAc,GAAG,MAAM,aAAa,CACxC,MAAM,EACN,CAAC,IAAI,EAAE,2BAA2B,YAAY,yBAAyB,CAAC,EACxE;QACE,GAAG,EAAE,SAAS;KACf,CACF,CAAA;IAED,IAAI,CAAC,cAAc,EAAE;QACnB,OAAM;KACP;IAED,MAAM,mBAAmB,GAAG,MAAM,kBAAkB,CAAC,YAAY,EAAE,cAAc,CAAC,CAAA;IAElF,IAAI,mBAAmB,EAAE;QACvB,UAAU,CAAC;YACT,QAAQ,EAAE,mBAAmB;YAC7B,IAAI,EACF,WAAW,mBAAmB,OAAO,YAAY,wBAAwB;gBACzE,8BAA8B,cAAc,GAAG;YACjD,SAAS,EAAE;gBACT;oBACE,IAAI,EAAE;wBACJ,KAAK,EAAE,mBAAmB;wBAC1B,GAAG,EAAE,8CAA8C;qBACpD;iBACF;aACF;SACF,CAAC,CAAA;QAEF,OAAO,mBAAmB,CAAA;KAC3B;AACH,CAAC","sourcesContent":["import {checkForNewVersion} from '@shopify/cli-kit/node/node-package-manager'\nimport {captureOutput} from '@shopify/cli-kit/node/system'\nimport {renderInfo} from '@shopify/cli-kit/node/ui'\n\nconst PACKAGE_NAME = '@shopify/hydrogen'\n\nexport async function checkHydrogenVersion(directory: string): Promise<string | undefined> {\n const currentVersion = await captureOutput(\n 'node',\n ['-p', `require('./node_modules/${PACKAGE_NAME}/package.json').version`],\n {\n cwd: directory,\n },\n )\n\n if (!currentVersion) {\n return\n }\n\n const newVersionAvailable = await checkForNewVersion(PACKAGE_NAME, currentVersion)\n\n if (newVersionAvailable) {\n renderInfo({\n headline: 'Upgrade available',\n body:\n `Version ${newVersionAvailable} of ${PACKAGE_NAME} is now available.\\n\\n` +\n `You are currently running v${currentVersion}.`,\n reference: [\n {\n link: {\n label: 'Hydrogen releases',\n url: 'https://github.com/Shopify/hydrogen/releases',\n },\n },\n ],\n })\n\n return newVersionAvailable\n }\n}\n"]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { genericConfigurationFileNames } from '../constants.js';
|
|
2
|
-
import { ui, npm,
|
|
2
|
+
import { ui, npm, path, error } from '@shopify/cli-kit';
|
|
3
3
|
import { addNPMDependenciesWithoutVersionIfNeeded } from '@shopify/cli-kit/node/node-package-manager';
|
|
4
4
|
import { addRecommendedExtensions, isVSCode } from '@shopify/cli-kit/node/vscode';
|
|
5
|
+
import { isUnitTest } from '@shopify/cli-kit/node/environment/local';
|
|
6
|
+
import { writeFile, fileExists, removeFile, fileContentPrettyFormat } from '@shopify/cli-kit/node/fs';
|
|
5
7
|
import stream from 'stream';
|
|
6
8
|
export async function addESLint({ app, force, install }) {
|
|
7
9
|
const list = ui.newListr([
|
|
@@ -34,9 +36,9 @@ export async function addESLint({ app, force, install }) {
|
|
|
34
36
|
title: 'Adding ESLint configuration',
|
|
35
37
|
task: async (_, task) => {
|
|
36
38
|
const eslintConfigPath = path.join(app.directory, genericConfigurationFileNames.eslint);
|
|
37
|
-
if (await
|
|
39
|
+
if (await fileExists(eslintConfigPath)) {
|
|
38
40
|
if (force) {
|
|
39
|
-
await
|
|
41
|
+
await removeFile(eslintConfigPath);
|
|
40
42
|
}
|
|
41
43
|
else {
|
|
42
44
|
throw new error.Abort('ESLint config already exists.', 'Use --force to override existing config.');
|
|
@@ -46,8 +48,8 @@ export async function addESLint({ app, force, install }) {
|
|
|
46
48
|
if (app.language === 'TypeScript') {
|
|
47
49
|
extended.push(`'plugin:hydrogen/typescript'`);
|
|
48
50
|
}
|
|
49
|
-
const eslintConfig = await
|
|
50
|
-
await
|
|
51
|
+
const eslintConfig = await fileContentPrettyFormat(['module.exports = {', 'extends: [', `${extended.join(',')}`, ' ],', ' };'].join('\n'), { path: genericConfigurationFileNames.eslint });
|
|
52
|
+
await writeFile(eslintConfigPath, eslintConfig);
|
|
51
53
|
task.title = 'ESLint configuration added';
|
|
52
54
|
},
|
|
53
55
|
},
|
|
@@ -69,7 +71,7 @@ export async function addESLint({ app, force, install }) {
|
|
|
69
71
|
task.title = 'Editor plugin recommendations added';
|
|
70
72
|
},
|
|
71
73
|
},
|
|
72
|
-
], { rendererSilent:
|
|
74
|
+
], { rendererSilent: isUnitTest() });
|
|
73
75
|
await list.run();
|
|
74
76
|
}
|
|
75
77
|
//# sourceMappingURL=eslint.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eslint.js","sourceRoot":"","sources":["../../../src/cli/services/eslint.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,6BAA6B,EAAC,MAAM,iBAAiB,CAAA;AAC7D,OAAO,EAAC,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"eslint.js","sourceRoot":"","sources":["../../../src/cli/services/eslint.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,6BAA6B,EAAC,MAAM,iBAAiB,CAAA;AAC7D,OAAO,EAAC,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAC,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAC,wCAAwC,EAAC,MAAM,4CAA4C,CAAA;AACnG,OAAO,EAAC,wBAAwB,EAAE,QAAQ,EAAC,MAAM,8BAA8B,CAAA;AAC/E,OAAO,EAAC,UAAU,EAAC,MAAM,yCAAyC,CAAA;AAClE,OAAO,EAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,uBAAuB,EAAC,MAAM,0BAA0B,CAAA;AACnG,OAAO,MAAM,MAAM,QAAQ,CAAA;AAQ3B,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,EAAC,GAAG,EAAE,KAAK,EAAE,OAAO,EAAmB;IACrE,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,CACtB;QACE;YACE,KAAK,EAAE,oCAAoC;YAC3C,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,OAAO;YACpB,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE;gBACtB,MAAM,oBAAoB,GAAG,CAAC,QAAQ,EAAE,wBAAwB,EAAE,UAAU,EAAE,0BAA0B,CAAC,CAAA;gBACzG,MAAM,wC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AAA;AAClB,CAAC","sourcesContent":["import {HydrogenApp} from '../models/hydrogen.js'\nimport {genericConfigurationFileNames} from '../constants.js'\nimport {ui, npm, path, error} from '@shopify/cli-kit'\nimport {addNPMDependenciesWithoutVersionIfNeeded} from '@shopify/cli-kit/node/node-package-manager'\nimport {addRecommendedExtensions, isVSCode} from '@shopify/cli-kit/node/vscode'\nimport {isUnitTest} from '@shopify/cli-kit/node/environment/local'\nimport {writeFile, fileExists, removeFile, fileContentPrettyFormat} from '@shopify/cli-kit/node/fs'\nimport stream from 'stream'\n\ninterface AddESlintOptions {\n app: HydrogenApp\n force: boolean\n install: boolean\n}\n\nexport async function addESLint({app, force, install}: AddESlintOptions) {\n const list = ui.newListr(\n [\n {\n title: 'Installing additional dependencies',\n skip: () => !install,\n task: async (_, task) => {\n const requiredDependencies = ['eslint', 'eslint-plugin-hydrogen', 'prettier', '@shopify/prettier-config']\n await addNPMDependenciesWithoutVersionIfNeeded(requiredDependencies, {\n packageManager: app.packageManager,\n type: 'prod',\n directory: app.directory,\n stderr: new stream.Writable({\n write(chunk, encoding, next) {\n task.output = chunk.toString()\n next()\n },\n }),\n stdout: new stream.Writable({\n write(chunk, encoding, next) {\n task.output = chunk.toString()\n next()\n },\n }),\n })\n task.title = 'Dependencies installed'\n },\n },\n\n {\n title: 'Adding ESLint configuration',\n task: async (_, task) => {\n const eslintConfigPath = path.join(app.directory, genericConfigurationFileNames.eslint)\n\n if (await fileExists(eslintConfigPath)) {\n if (force) {\n await removeFile(eslintConfigPath)\n } else {\n throw new error.Abort('ESLint config already exists.', 'Use --force to override existing config.')\n }\n }\n\n const extended = [`'plugin:hydrogen/recommended'`]\n\n if (app.language === 'TypeScript') {\n extended.push(`'plugin:hydrogen/typescript'`)\n }\n\n const eslintConfig = await fileContentPrettyFormat(\n ['module.exports = {', 'extends: [', `${extended.join(',')}`, ' ],', ' };'].join('\\n'),\n {path: genericConfigurationFileNames.eslint},\n )\n\n await writeFile(eslintConfigPath, eslintConfig)\n\n task.title = 'ESLint configuration added'\n },\n },\n {\n title: 'Updating package.json',\n task: async (_, task) => {\n const packageJSON = await npm.readPackageJSON(app.directory)\n\n packageJSON.scripts.lint = `eslint --ext .js,.ts,.jsx,.tsx src/`\n\n packageJSON.prettier = '@shopify/prettier-config'\n\n await npm.writePackageJSON(app.directory, packageJSON)\n\n task.title = 'Package.json updated'\n },\n },\n {\n title: 'Adding editor plugin recommendations',\n skip: async () => !(await isVSCode(app.directory)),\n task: async (_, task) => {\n await addRecommendedExtensions(app.directory, ['dbaeumer.vscode-eslint'])\n task.title = 'Editor plugin recommendations added'\n },\n },\n ],\n {rendererSilent: isUnitTest()},\n )\n await list.run()\n}\n"]}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import { path, error,
|
|
1
|
+
import { path, error, output } from '@shopify/cli-kit';
|
|
2
2
|
import { readAndParseDotEnv } from '@shopify/cli-kit/node/dot-env';
|
|
3
|
+
import { fileExists, removeFileSync, writeFile } from '@shopify/cli-kit/node/fs';
|
|
4
|
+
import { exec } from '@shopify/cli-kit/node/system';
|
|
3
5
|
import { fileURLToPath } from 'url';
|
|
4
6
|
export async function previewInNode({ directory, port }) {
|
|
5
7
|
const buildOutputPath = await path.resolve(directory, 'dist/node');
|
|
6
|
-
if (!(await
|
|
8
|
+
if (!(await fileExists(buildOutputPath))) {
|
|
7
9
|
output.info(output.content `Couldn’t find a Node.js server build for this project. Running ${output.token.packagejsonScript('yarn', 'shopify hydrogen build', '--target=node')} to create one.`);
|
|
8
|
-
await
|
|
10
|
+
await exec('yarn', ['shopify', 'hydrogen', 'build', '--target=node'], {
|
|
9
11
|
cwd: directory,
|
|
10
12
|
stdout: process.stdout,
|
|
11
13
|
stderr: process.stderr,
|
|
12
14
|
});
|
|
13
15
|
}
|
|
14
|
-
await
|
|
16
|
+
await exec('node', ['--enable-source-maps', buildOutputPath], {
|
|
15
17
|
env: { PORT: `${port}` },
|
|
16
18
|
cwd: directory,
|
|
17
19
|
stdout: process.stdout,
|
|
@@ -30,10 +32,10 @@ export async function previewInWorker({ directory, port, envPath }) {
|
|
|
30
32
|
autoReload: true,
|
|
31
33
|
...(envPath && (await parseEnvPath(envPath))),
|
|
32
34
|
};
|
|
33
|
-
await
|
|
35
|
+
await writeFile(path.resolve(directory, 'mini-oxygen.config.json'), JSON.stringify(config, null, 2));
|
|
34
36
|
function cleanUp(options) {
|
|
35
37
|
if (options.exit) {
|
|
36
|
-
|
|
38
|
+
removeFileSync(path.resolve(directory, 'mini-oxygen.config.json'));
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
41
|
async function parseEnvPath(envPath) {
|
|
@@ -44,7 +46,7 @@ export async function previewInWorker({ directory, port, envPath }) {
|
|
|
44
46
|
}
|
|
45
47
|
process.on('SIGINT', cleanUp.bind(null, { exit: true }));
|
|
46
48
|
const executable = await oxygenPreviewExecutable();
|
|
47
|
-
await
|
|
49
|
+
await exec(executable, [], {
|
|
48
50
|
env: { NODE_OPTIONS: '--experimental-vm-modules' },
|
|
49
51
|
cwd: directory,
|
|
50
52
|
stdout: process.stdout,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview.js","sourceRoot":"","sources":["../../../src/cli/services/preview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAE,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"preview.js","sourceRoot":"","sources":["../../../src/cli/services/preview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAC,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAC,kBAAkB,EAAa,MAAM,+BAA+B,CAAA;AAC5E,OAAO,EAAC,UAAU,EAAE,cAAc,EAAE,SAAS,EAAC,MAAM,0BAA0B,CAAA;AAC9E,OAAO,EAAC,IAAI,EAAC,MAAM,8BAA8B,CAAA;AACjD,OAAO,EAAC,aAAa,EAAC,MAAM,KAAK,CAAA;AAejC,MAAM,CAAC,KAAK,UAAU,aA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C,CAAA;IACtH,IAAI,CAAC,cAAc,EAAE;QACnB,MAAM,+BAA+B,CAAA;KACtC;IACD,OAAO,cAAc,CAAA;AACvB,CAAC","sourcesContent":["import {path, error, output} from '@shopify/cli-kit'\nimport {readAndParseDotEnv, DotEnvFile} from '@shopify/cli-kit/node/dot-env'\nimport {fileExists, removeFileSync, writeFile} from '@shopify/cli-kit/node/fs'\nimport {exec} from '@shopify/cli-kit/node/system'\nimport {fileURLToPath} from 'url'\n\ninterface PreviewOptions {\n directory: string\n port: number\n}\n\ninterface PreviewOptionsWorker extends PreviewOptions {\n envPath: string | undefined\n}\n\ninterface EnvConfig {\n env: DotEnvFile['variables']\n}\n\nexport async function previewInNode({directory, port}: PreviewOptions) {\n const buildOutputPath = await path.resolve(directory, 'dist/node')\n\n if (!(await fileExists(buildOutputPath))) {\n output.info(\n output.content`Couldn’t find a Node.js server build for this project. Running ${output.token.packagejsonScript(\n 'yarn',\n 'shopify hydrogen build',\n '--target=node',\n )} to create one.`,\n )\n\n await exec('yarn', ['shopify', 'hydrogen', 'build', '--target=node'], {\n cwd: directory,\n stdout: process.stdout,\n stderr: process.stderr,\n })\n }\n\n await exec('node', ['--enable-source-maps', buildOutputPath], {\n env: {PORT: `${port}`},\n cwd: directory,\n stdout: process.stdout,\n stderr: process.stderr,\n })\n}\n\nexport async function previewInWorker({directory, port, envPath}: PreviewOptionsWorker) {\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 ...(envPath && (await parseEnvPath(envPath))),\n }\n\n await writeFile(path.resolve(directory, 'mini-oxygen.config.json'), JSON.stringify(config, null, 2))\n\n function cleanUp(options: {exit: boolean}) {\n if (options.exit) {\n removeFileSync(path.resolve(directory, 'mini-oxygen.config.json'))\n }\n }\n\n async function parseEnvPath(envPath: string): Promise<EnvConfig> {\n const {variables} = await readAndParseDotEnv(envPath)\n return {\n env: variables,\n }\n }\n\n process.on('SIGINT', cleanUp.bind(null, {exit: true}))\n\n const executable = await oxygenPreviewExecutable()\n\n await exec(executable, [], {\n env: {NODE_OPTIONS: '--experimental-vm-modules'},\n cwd: directory,\n stdout: process.stdout,\n stderr: process.stderr,\n })\n}\n\nexport const OxygenPreviewExecutableNotFound = new error.Bug(\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, allowSymlinks: true})\n if (!executablePath) {\n throw OxygenPreviewExecutableNotFound\n }\n return executablePath\n}\n"]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { ui,
|
|
1
|
+
import { ui, path, error } from '@shopify/cli-kit';
|
|
2
2
|
import { addNPMDependenciesWithoutVersionIfNeeded } from '@shopify/cli-kit/node/node-package-manager';
|
|
3
3
|
import { addRecommendedExtensions } from '@shopify/cli-kit/node/vscode';
|
|
4
|
+
import { exec } from '@shopify/cli-kit/node/system';
|
|
5
|
+
import { writeFile, fileExists, removeFile, fileContentPrettyFormat, readFile } from '@shopify/cli-kit/node/fs';
|
|
4
6
|
import stream from 'stream';
|
|
5
7
|
const tailwindImports = [
|
|
6
8
|
"@import 'tailwindcss/base';",
|
|
@@ -39,16 +41,16 @@ export async function addTailwind({ app, force, install, directory }) {
|
|
|
39
41
|
title: 'Adding PostCSS configuration',
|
|
40
42
|
task: async (_, task) => {
|
|
41
43
|
const postCSSConfiguration = path.join(directory, 'postcss.config.js');
|
|
42
|
-
if (await
|
|
44
|
+
if (await fileExists(postCSSConfiguration)) {
|
|
43
45
|
if (force) {
|
|
44
|
-
await
|
|
46
|
+
await removeFile(postCSSConfiguration);
|
|
45
47
|
}
|
|
46
48
|
else {
|
|
47
49
|
throw new error.Abort('PostCSS config already exists.\nUse --force to override existing config.');
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
|
-
const postCSSConfig = await
|
|
51
|
-
await
|
|
52
|
+
const postCSSConfig = await fileContentPrettyFormat(['module.exports = {', 'plugins: {', 'tailwindcss: {},', 'autoprefixer: {},', '},', ' };'].join('\n'), { path: 'postcss.config.js' });
|
|
53
|
+
await writeFile(postCSSConfiguration, postCSSConfig);
|
|
52
54
|
task.title = 'PostCSS configuration added';
|
|
53
55
|
},
|
|
54
56
|
},
|
|
@@ -56,15 +58,15 @@ export async function addTailwind({ app, force, install, directory }) {
|
|
|
56
58
|
title: 'Initializing Tailwind CSS...',
|
|
57
59
|
task: async (_, task) => {
|
|
58
60
|
const tailwindConfigurationPath = path.join(directory, 'tailwind.config.js');
|
|
59
|
-
if (await
|
|
61
|
+
if (await fileExists(tailwindConfigurationPath)) {
|
|
60
62
|
if (force) {
|
|
61
|
-
await
|
|
63
|
+
await removeFile(tailwindConfigurationPath);
|
|
62
64
|
}
|
|
63
65
|
else {
|
|
64
66
|
throw new error.Abort('Tailwind config already exists.\nUse --force to override existing config.');
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
|
-
await
|
|
69
|
+
await exec(app.packageManager, ['tailwindcss', 'init', tailwindConfigurationPath], {
|
|
68
70
|
cwd: directory,
|
|
69
71
|
});
|
|
70
72
|
await replace('content: []', "content: ['./index.html', './src/**/*.{js,jsx,ts,tsx}']", tailwindConfigurationPath);
|
|
@@ -75,13 +77,13 @@ export async function addTailwind({ app, force, install, directory }) {
|
|
|
75
77
|
title: 'Importing Tailwind CSS in index.css',
|
|
76
78
|
task: async (_ctx, task) => {
|
|
77
79
|
const indexCSSPath = path.join(directory, 'src', 'index.css');
|
|
78
|
-
const indexCSS = await
|
|
80
|
+
const indexCSS = await readFile(indexCSSPath);
|
|
79
81
|
if (tailwindImportsExist(indexCSS)) {
|
|
80
82
|
task.skip('Imports already exist in index.css');
|
|
81
83
|
}
|
|
82
84
|
else {
|
|
83
85
|
const newIndexCSS = tailwindImports.join('\n') + indexCSS;
|
|
84
|
-
await
|
|
86
|
+
await writeFile(indexCSSPath, newIndexCSS);
|
|
85
87
|
}
|
|
86
88
|
task.title = 'Tailwind imports added';
|
|
87
89
|
},
|
|
@@ -97,8 +99,8 @@ export async function addTailwind({ app, force, install, directory }) {
|
|
|
97
99
|
await list.run();
|
|
98
100
|
}
|
|
99
101
|
async function replace(find, replace, filepath) {
|
|
100
|
-
const original = await
|
|
102
|
+
const original = await readFile(filepath);
|
|
101
103
|
const modified = original.replace(find, replace);
|
|
102
|
-
await
|
|
104
|
+
await writeFile(filepath, modified);
|
|
103
105
|
}
|
|
104
106
|
//# sourceMappingURL=tailwind.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tailwind.js","sourceRoot":"","sources":["../../../src/cli/services/tailwind.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"tailwind.js","sourceRoot":"","sources":["../../../src/cli/services/tailwind.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAC,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAC,wCAAwC,EAAC,MAAM,4CAA4C,CAAA;AACnG,OAAO,EAAC,wBAAwB,EAAC,MAAM,8BAA8B,CAAA;AACrE,OAAO,EAAC,IAAI,EAAC,MAAM,8BAA8B,CAAA;AACjD,OAAO,EAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,uBAAuB,EAAE,QAAQ,EAAC,MAAM,0BAA0B,CAAA;AAC7G,OAAO,MAAM,MAAM,QAAQ,CAAA;AAS3B,MAAM,eAAe,GAAG;IACtB,6BAA6B;IAC7B,mCAAmC;IACnC,kCAAkC;CACnC,CAAA;AAED,MAAM,oBAAoB,GAAG,CAAC,QAAgB,EAAE,EAAE,CAChD,eAAe,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,iB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, error} from '@shopify/cli-kit'\nimport {addNPMDependenciesWithoutVersionIfNeeded} from '@shopify/cli-kit/node/node-package-manager'\nimport {addRecommendedExtensions} from '@shopify/cli-kit/node/vscode'\nimport {exec} from '@shopify/cli-kit/node/system'\nimport {writeFile, fileExists, removeFile, fileContentPrettyFormat, readFile} from '@shopify/cli-kit/node/fs'\nimport stream from 'stream'\n\ninterface AddTailwindOptions {\n app: HydrogenApp\n force: boolean\n directory: string\n install: boolean\n}\n\nconst tailwindImports = [\n \"@import 'tailwindcss/base';\",\n \"@import 'tailwindcss/components';\",\n \"@import 'tailwindcss/utilities';\",\n]\n\nconst tailwindImportsExist = (indexCSS: string) =>\n tailwindImports.map((el) => new RegExp(el)).every((tailwindDirective) => tailwindDirective.test(indexCSS))\n\nexport async function addTailwind({app, force, install, directory}: AddTailwindOptions) {\n const list = ui.newListr([\n {\n title: 'Installing additional dependencies',\n skip: () => !install,\n task: async (_, task) => {\n const requiredDependencies = ['postcss', 'postcss-loader', 'tailwindcss', 'autoprefixer']\n await addNPMDependenciesWithoutVersionIfNeeded(requiredDependencies, {\n packageManager: app.packageManager,\n type: 'prod',\n directory: app.directory,\n stderr: new stream.Writable({\n write(chunk, encoding, next) {\n task.output = chunk.toString()\n next()\n },\n }),\n stdout: new stream.Writable({\n write(chunk, encoding, next) {\n task.output = chunk.toString()\n next()\n },\n }),\n })\n task.title = 'Dependencies installed'\n },\n },\n\n {\n title: 'Adding PostCSS configuration',\n task: async (_, task) => {\n const postCSSConfiguration = path.join(directory, 'postcss.config.js')\n\n if (await fileExists(postCSSConfiguration)) {\n if (force) {\n await removeFile(postCSSConfiguration)\n } else {\n throw new error.Abort('PostCSS config already exists.\\nUse --force to override existing config.')\n }\n }\n\n const postCSSConfig = await fileContentPrettyFormat(\n ['module.exports = {', 'plugins: {', 'tailwindcss: {},', 'autoprefixer: {},', '},', ' };'].join('\\n'),\n {path: 'postcss.config.js'},\n )\n\n await writeFile(postCSSConfiguration, postCSSConfig)\n\n task.title = 'PostCSS configuration added'\n },\n },\n\n {\n title: 'Initializing Tailwind CSS...',\n task: async (_, task) => {\n const tailwindConfigurationPath = path.join(directory, 'tailwind.config.js')\n\n if (await fileExists(tailwindConfigurationPath)) {\n if (force) {\n await removeFile(tailwindConfigurationPath)\n } else {\n throw new error.Abort('Tailwind config already exists.\\nUse --force to override existing config.')\n }\n }\n\n await exec(app.packageManager, ['tailwindcss', 'init', tailwindConfigurationPath], {\n cwd: directory,\n })\n\n await replace(\n 'content: []',\n \"content: ['./index.html', './src/**/*.{js,jsx,ts,tsx}']\",\n tailwindConfigurationPath,\n )\n\n task.title = 'Tailwind configuration added'\n },\n },\n {\n title: 'Importing Tailwind CSS in index.css',\n task: async (_ctx, task) => {\n const indexCSSPath = path.join(directory, 'src', 'index.css')\n const indexCSS = await readFile(indexCSSPath)\n\n if (tailwindImportsExist(indexCSS)) {\n task.skip('Imports already exist in index.css')\n } else {\n const newIndexCSS = tailwindImports.join('\\n') + indexCSS\n\n await writeFile(indexCSSPath, newIndexCSS)\n }\n\n task.title = 'Tailwind imports added'\n },\n },\n {\n title: 'Adding editor plugin recommendations',\n task: async (_, task) => {\n await addRecommendedExtensions(directory, ['csstools.postcss', 'bradlc.vscode-tailwindcss'])\n task.title = 'Editor plugin recommendations added'\n },\n },\n ])\n await list.run()\n}\n\nasync function replace(find: string | RegExp, replace: string, filepath: string) {\n const original = await readFile(filepath)\n const modified = original.replace(find, replace)\n await writeFile(filepath, modified)\n}\n"]}
|