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
5 changes: 5 additions & 0 deletions .changeset/bright-auth-skeleton.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/dev-platform-auth': minor
---

Add the `@shopify/dev-platform-auth` package skeleton.
3 changes: 2 additions & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"@shopify/cli-kit",
"@shopify/theme",
"@shopify/plugin-cloudflare",
"@shopify/plugin-did-you-mean"
"@shopify/plugin-did-you-mean",
"@shopify/dev-platform-auth"
]],
"access": "public",
"baseBranch": "main",
Expand Down
11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,17 @@
]
}
},
"packages/dev-platform-auth": {
"entry": [
"**/index.ts!"
],
"project": "**/*.ts!",
"vite": {
"config": [
"vite.config.ts"
]
}
},
"packages/store": {
"entry": [
"**/{commands,hooks}/**/*.ts!",
Expand Down
7 changes: 7 additions & 0 deletions packages/dev-platform-auth/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @shopify/dev-platform-auth

`@shopify/dev-platform-auth` provides portable Shopify developer auth flows.

This package is currently a skeleton. Identity device flow and `client_credentials` flow modules will arrive in subsequent pull requests.

The portability contract is ESM on Node.js >=20, with no Node built-ins in the `.` entry. Only `.` and `./testing` are exported.
56 changes: 56 additions & 0 deletions packages/dev-platform-auth/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "@shopify/dev-platform-auth",
"version": "4.6.0",
"packageManager": "pnpm@10.11.1",
"private": false,
"description": "Portable Shopify developer auth flows",
"homepage": "https://github.com/shopify/cli#readme",
"bugs": {
"url": "https://community.shopify.dev/c/shopify-cli-libraries/14"
},
"repository": {
"type": "git",
"url": "https://github.com/Shopify/cli.git",
"directory": "packages/dev-platform-auth"
},
"license": "MIT",
"type": "module",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"node": "./dist/index.js"
},
"./testing": {
"types": "./dist/testing/index.d.ts",
"import": "./dist/testing/index.js",
"node": "./dist/testing/index.js"
}
},
"files": ["dist"],
"scripts": {
"build": "nx build",
"clean": "nx clean",
"lint": "nx lint",
"lint:fix": "nx lint:fix",
"type-check": "nx type-check",
"vitest": "vitest"
},
"eslintConfig": {
"extends": ["../../.eslintrc.cjs"]
},
"devDependencies": {
"@types/node": "18.19.130",
"@vitest/coverage-istanbul": "^3.2.7",
"esbuild": "0.28.1"
},
"engines": {
"node": ">=20.10.0"
},
"publishConfig": {
"@shopify:registry": "https://registry.npmjs.org",
"access": "public"
},
"sideEffects": false,
"engine-strict": true
}
46 changes: 46 additions & 0 deletions packages/dev-platform-auth/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "dev-platform-auth",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/dev-platform-auth/src",
"projectType": "library",
"tags": ["scope:foundation"],
"targets": {
"clean": {
"executor": "nx:run-commands",
"options": {
"command": "pnpm rimraf dist/",
"cwd": "packages/dev-platform-auth"
}
},
"build": {
"executor": "nx:run-commands",
"outputs": ["{workspaceRoot}/packages/dev-platform-auth/dist"],
"inputs": ["{projectRoot}/src/**/*", "{projectRoot}/package.json", "{projectRoot}/tsconfig.build.json"],
"options": {
"command": "pnpm tsc -b ./tsconfig.build.json",
"cwd": "packages/dev-platform-auth"
}
},
"lint": {
"executor": "nx:run-commands",
"options": {
"command": "pnpm eslint src",
"cwd": "packages/dev-platform-auth"
}
},
"lint:fix": {
"executor": "nx:run-commands",
"options": {
"command": "pnpm eslint src --fix",
"cwd": "packages/dev-platform-auth"
}
},
"type-check": {
"executor": "nx:run-commands",
"options": {
"command": "pnpm tsc --noEmit",
"cwd": "packages/dev-platform-auth"
}
}
}
}
3 changes: 3 additions & 0 deletions packages/dev-platform-auth/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const PACKAGE_NAME = '@shopify/dev-platform-auth'

export type AuthFlowPlaceholder = 'skeleton'
38 changes: 38 additions & 0 deletions packages/dev-platform-auth/src/portability.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* eslint-disable no-restricted-imports, import-x/order */
import {execFileSync} from 'node:child_process'
import {readFileSync} from 'node:fs'
import {resolve} from 'node:path'
import {build} from 'esbuild'
import {describe, expect, test} from 'vitest'

const packageRoot = resolve(__dirname, '..')
const entry = resolve(packageRoot, 'dist/index.js')

function buildPackage() {
execFileSync('pnpm', ['exec', 'nx', 'build', 'dev-platform-auth'], {
cwd: resolve(packageRoot, '../..'),
stdio: 'ignore',
})
}

describe('package portability', () => {
test('can be consumed by plain JavaScript', () => {
buildPackage()
execFileSync(process.execPath, [resolve(packageRoot, 'tests/consumer.mjs')], {stdio: 'pipe'})
})

test('does not include Node built-ins or CommonJS in the portable entry', () => {
buildPackage()
const output = readFileSync(entry, 'utf8')
const nodeBuiltins =
/(?:node:)?(?:assert|buffer|child_process|cluster|crypto|dgram|dns|events|fs|http|https|module|net|os|path|perf_hooks|process|querystring|readline|stream|string_decoder|timers|tls|tty|url|util|v8|vm|worker_threads|zlib)/

expect(output).not.toMatch(nodeBuiltins)
expect(output).not.toContain('require(')
})

test('bundles for browsers without external dependencies', async () => {
buildPackage()
await expect(build({entryPoints: [entry], bundle: true, platform: 'browser', write: false})).resolves.toBeDefined()
})
})
1 change: 1 addition & 0 deletions packages/dev-platform-auth/src/testing/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const TESTING_PACKAGE_NAME = '@shopify/dev-platform-auth/testing'
5 changes: 5 additions & 0 deletions packages/dev-platform-auth/tests/consumer.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {PACKAGE_NAME} from '../dist/index.js'

if (PACKAGE_NAME !== '@shopify/dev-platform-auth') {
throw new Error(`Unexpected package name: ${PACKAGE_NAME}`)
}
4 changes: 4 additions & 0 deletions packages/dev-platform-auth/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["**/*.test.ts"]
}
14 changes: 14 additions & 0 deletions packages/dev-platform-auth/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "../../configurations/tsconfig.json",
"include": ["./src/**/*.ts"],
"exclude": ["./dist"],
"compilerOptions": {
"lib": ["ES2022"],
"target": "ES2022",
"outDir": "dist",
"rootDir": "src",
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo",
"types": ["node", "vitest/importMeta"]
},
"references": []
}
3 changes: 3 additions & 0 deletions packages/dev-platform-auth/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import config from '../../configurations/vite.config'

export default config(__dirname)
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading