Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 10 additions & 21 deletions packages/ui-extensions/docs/surfaces/build-doc-shared.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,22 @@ import childProcess from 'child_process';
import fs from 'fs/promises';
import {existsSync} from 'fs';
import path from 'path';
import readline from 'readline/promises';
import process, {stdin as input, stdout as output} from 'process';
import process from 'process';

export const resolveShopifyDevPath = async (rootPath) => {
const defaultPath = path.resolve(rootPath, '../../../shopify-dev');
if (existsSync(defaultPath)) return defaultPath;

const rl = readline.createInterface({input, output});
const answer = (
await rl.question(
`\n\x1b[33m⚠️ Shopify dev directory not found at:\x1b[0m \x1b[1m${defaultPath}\x1b[0m\n\x1b[32mPlease provide the absolute path to your "shopify-dev" repo:\x1b[0m `,
)
).trim();
rl.close();
export const resolveShopifyDevPath = async () => {
const worldPath = path.join(
process.env.HOME,
'world/trees/root/src/areas/platforms/shopify-dev',
);

const shopifyDevPath = answer ? path.resolve(answer) : '';
if (!shopifyDevPath || !existsSync(shopifyDevPath)) {
if (!existsSync(worldPath)) {
throw new Error(
`\x1b[31m❌ Error: ${
shopifyDevPath
? `shopify-dev directory not found at ${shopifyDevPath}.`
: 'Path cannot be empty.'
} Check the path and try again!\x1b[0m`,
`\x1b[31m❌ Error: shopify-dev not found at ${worldPath}.\n` +
`Run: tec checkout add //areas/platforms/shopify-dev\x1b[0m`,
);
}

return shopifyDevPath;
return worldPath;
};

export const replaceFileContent = async ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const srcRelativePath = 'src/surfaces/point-of-sale';
const docsPath = path.join(rootPath, docsRelativePath);
const srcPath = path.join(rootPath, srcRelativePath);
const generatedDocsPath = path.join(docsPath, 'generated');
const shopifyDevPath = await resolveShopifyDevPath(rootPath);
const shopifyDevPath = await resolveShopifyDevPath();
const shopifyDevDBPath = path.join(
shopifyDevPath,
'areas/platforms/shopify-dev/db/data/docs/templated_apis',
Expand Down
Loading