Skip to content
Draft
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ eslint-report.json
docs/api
docs-shopify.dev/commands/interfaces/

# Generated Shopify developer skills
packages/skills/

vite.config.ts.timestamp*

# from nested gitignores
Expand Down
44 changes: 44 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@
"use-resize-observer>react-dom": "19.2.4"
}
},
"overrides": {
"@shopify/shopify-dev-tools>@shopify/verdict": "-"
},
"onlyBuiltDependencies": [
"@parcel/watcher",
"esbuild",
Expand Down Expand Up @@ -379,6 +382,47 @@
"@types/react-dom",
"react-dom"
]
},
"packages/shopify-dev-tools": {
"entry": [
"src/index.ts!",
"src/instructions/skill-blocks.ts!",
"src/schemaOperations/loadAPISchemas.ts!",
"src/validation/extractComponentValidations.ts!",
"src/validation/format.ts!",
"scripts/*.{js,ts}!",
"src/agent-skills/scripts/*.ts!"
],
"project": [
"src/**/*.ts!",
"scripts/*.{js,ts}!",
"test-stubs/**/*.ts!",
"vite.config.js!"
],
"ignore": [
"src/data/**"
],
"ignoreDependencies": [
"@react-router/dev",
"@react-router/node",
"@shopify/app-bridge-react",
"@shopify/app-bridge-types",
"@shopify/hydrogen",
"@shopify/hydrogen-react",
"@shopify/polaris-types",
"@shopify/verdict",
"@types/react",
"isbot",
"preact",
"react-router",
"schema-dts",
"type-fest"
],
"vite": {
"config": [
"vite.config.js"
]
}
}
}
}
Expand Down
10 changes: 9 additions & 1 deletion packages/shopify-dev-tools/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@ npm-debug.log*
# TypeScript build info
*.tsbuildinfo

# The repository-wide ignore rules exclude nested dist directories and
# generated-looking index declarations. Here they are vendored reference data,
# not build output, so they must remain tracked.
!src/data/types/**/dist/
!src/data/types/**/dist/**
!src/data/types/**/index.d.ts

data/*.json

# Generated by scripts/embed-schemas.ts (pnpm embed-schemas)
# Generated by package build and maintenance scripts.
src/data-embedded/
src/data/mcp-instructions/
12 changes: 7 additions & 5 deletions packages/shopify-dev-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,15 @@
"embed-schemas": "pnpm exec tsx scripts/embed-schemas.ts",
"generate_api_instructions": "pnpm exec tsx scripts/generate-api-instructions.ts",
"generate_agent_skills": "pnpm exec tsx scripts/generate-agent-skills.ts",
"build": "pnpm embed-schemas && pnpm exec tsx scripts/generate-api-instructions.ts && vite build && tsc --emitDeclarationOnly",
"update-apis": "node scripts/update-apis.mjs",
"build": "nx build",
"build:watch": "pnpm embed-schemas && vite build --watch",
"test": "vitest run",
"clean": "nx clean",
"test": "nx test",
"test:watch": "vitest",
"typecheck": "pnpm embed-schemas && tsc --noEmit",
"lint": "prettier --check --cache --ignore-unknown .",
"lint:fix": "prettier --write --ignore-unknown ."
"typecheck": "nx type-check",
"lint": "nx lint",
"lint:fix": "nx lint:fix"
},
"dependencies": {
"@shopify/app-bridge-react": "catalog:",
Expand Down
59 changes: 59 additions & 0 deletions packages/shopify-dev-tools/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"name": "shopify-dev-tools",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/shopify-dev-tools/src",
"projectType": "library",
"tags": ["scope:feature"],
"targets": {
"clean": {
"executor": "nx:run-commands",
"options": {
"command": "pnpm rimraf dist/",
"cwd": "packages/shopify-dev-tools"
}
},
"build": {
"executor": "nx:run-commands",
"outputs": ["{projectRoot}/dist"],
"inputs": [
"{projectRoot}/src/**/*",
"{projectRoot}/scripts/**/*",
"{projectRoot}/package.json",
"{projectRoot}/tsconfig.json",
"{projectRoot}/vite.config.js"
],
"options": {
"command": "pnpm embed-schemas && pnpm generate_api_instructions && pnpm exec vite build && pnpm exec tsc --emitDeclarationOnly",
"cwd": "packages/shopify-dev-tools"
}
},
"lint": {
"executor": "nx:run-commands",
"options": {
"command": "pnpm exec prettier --check --cache --ignore-unknown .",
"cwd": "packages/shopify-dev-tools"
}
},
"lint:fix": {
"executor": "nx:run-commands",
"options": {
"command": "pnpm exec prettier --write --ignore-unknown .",
"cwd": "packages/shopify-dev-tools"
}
},
"test": {
"executor": "nx:run-commands",
"options": {
"command": "pnpm exec vitest run --config vite.config.js",
"cwd": "packages/shopify-dev-tools"
}
},
"type-check": {
"executor": "nx:run-commands",
"options": {
"command": "pnpm embed-schemas && pnpm exec tsc --noEmit",
"cwd": "packages/shopify-dev-tools"
}
}
}
}
34 changes: 34 additions & 0 deletions packages/shopify-dev-tools/src/types/verdict.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
declare module "@shopify/verdict/node" {
export type VariantAssignment = string;
export type VerdictError = unknown;

export interface VerdictUserConfiguration {
apiKey: string;
appName: string;
useEdgeApi: boolean;
cacheConfiguration: {
cacheTTLSeconds: number;
staleWhileRevalidateSeconds: number;
staleIfErrorSeconds: number;
};
fetchOptions: { timeout: number };
logger: {
produce(event: { schemaId: string; payload: unknown }): Promise<void>;
};
onError(err: unknown): void;
}

export class Verdict {
constructor(config: VerdictUserConfiguration);

assignVariant(
experimentHandle: string,
subject: { type: "default"; subjectId: string },
): Promise<VariantAssignment>;

flagEnabled(
flagHandle: string,
subject: { type: "default"; subjectId: string },
): Promise<boolean>;
}
}
34 changes: 34 additions & 0 deletions packages/shopify-dev-tools/test-stubs/verdict.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
export type VariantAssignment = string;
export type VerdictError = unknown;

export interface VerdictUserConfiguration {
apiKey: string;
appName: string;
useEdgeApi: boolean;
cacheConfiguration: {
cacheTTLSeconds: number;
staleWhileRevalidateSeconds: number;
staleIfErrorSeconds: number;
};
fetchOptions: { timeout: number };
logger: {
produce(event: { schemaId: string; payload: unknown }): Promise<void>;
};
onError(err: unknown): void;
}

export class Verdict {
constructor(_config: VerdictUserConfiguration) {}

async assignVariant(): Promise<VariantAssignment> {
throw new Error(
"The Verdict client is unavailable in the public repository test environment.",
);
}

async flagEnabled(): Promise<boolean> {
throw new Error(
"The Verdict client is unavailable in the public repository test environment.",
);
}
}
4 changes: 4 additions & 0 deletions packages/shopify-dev-tools/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export default defineConfig({
"graphql",
"typescript",
"html-tags",
"@shopify/verdict/node",
],
output: {
interop: "auto",
Expand All @@ -184,6 +185,9 @@ export default defineConfig({
alias: {
// Similar to the moduleNameMapper in Jest config
"^(\\.{1,2}/.*)\\.js$": "$1",
"@shopify/verdict/node": fileURLToPath(
new URL("./test-stubs/verdict.ts", import.meta.url),
),
},
},
});
Loading
Loading