@quatronic/sdk 0.7.0-test.3603305 → 0.7.0-test.581e6df

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.
@@ -1,12 +1,12 @@
1
+ import {
2
+ proxyMatcher
3
+ } from "../../chunk-X6D3TBNS.js";
1
4
  import {
2
5
  QORE_CSP_REPORT_URI,
3
6
  createCspReportRoute,
4
7
  readCspReport
5
8
  } from "../../chunk-P7HNHLW7.js";
6
9
  import "../../chunk-FUPTRHT7.js";
7
- import {
8
- proxyMatcher
9
- } from "../../chunk-X6D3TBNS.js";
10
10
  import {
11
11
  STATIC_SECURITY_HEADERS
12
12
  } from "../../chunk-2HE2D4SY.js";
@@ -1,6 +1,10 @@
1
1
  import {
2
2
  ALWAYS_EXCLUDED
3
3
  } from "../../chunk-X6D3TBNS.js";
4
+ import {
5
+ QORE_CSP_REPORT_URI
6
+ } from "../../chunk-P7HNHLW7.js";
7
+ import "../../chunk-FUPTRHT7.js";
4
8
 
5
9
  // src/next/security/testing.ts
6
10
  var DEFAULT_SESSION_COOKIES = [
@@ -36,6 +40,7 @@ function expectHeader(response, name, value) {
36
40
  );
37
41
  }
38
42
  }
43
+ var REPORT_URIS = ["/api/csp-report", QORE_CSP_REPORT_URI];
39
44
  function expectContains(actual, needle, what) {
40
45
  if (!actual.includes(needle)) {
41
46
  throw new Error(`${what}: expected it to contain ${JSON.stringify(needle)}, got ${JSON.stringify(actual)}`);
@@ -82,7 +87,11 @@ function securityHeaderChecks(target) {
82
87
  expectContains(first, "'strict-dynamic'", "content-security-policy");
83
88
  expectContains(first, "frame-ancestors 'none'", "content-security-policy");
84
89
  expectContains(first, "object-src 'none'", "content-security-policy");
85
- expectContains(first, "report-uri /api/csp-report", "content-security-policy");
90
+ if (!REPORT_URIS.some((uri) => first.includes(`report-uri ${uri}`))) {
91
+ throw new Error(
92
+ `content-security-policy: expected a report-uri of ${REPORT_URIS.join(" or ")}, got ${JSON.stringify(first)}`
93
+ );
94
+ }
86
95
  const nonce = nonceOf(first);
87
96
  if (!nonce) throw new Error(`content-security-policy carries no nonce: ${first}`);
88
97
  if (nonce === nonceOf(second)) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/next/security/testing.ts"],"sourcesContent":["import { ALWAYS_EXCLUDED } from \"../../security-core/proxy\"\nimport type { SecuredProxy } from \"./index\"\n\n/**\n * The security-header contract, as a list of checks an app runs against its own\n * proxy.\n *\n * These are not tests of `@quatronic/sdk` — this package has its own. They are\n * for the generated app, so that removing `withSecurityHeaders` from\n * `src/proxy.ts`, or matching so few routes that it stops running, fails that\n * app's build rather than being noticed in a penetration test.\n *\n * It returns checks rather than declaring them, so this module needs no test\n * runner of its own and works under whichever one the app uses:\n *\n * import { describe, it } from \"vitest\"\n * import { securityHeaderChecks } from \"@quatronic/sdk/next/security/testing\"\n * import { config, proxy } from \"@/proxy\"\n *\n * describe(\"security headers\", () => {\n * for (const check of securityHeaderChecks({ proxy, config })) it(check.name, check.run)\n * })\n *\n * A failing check throws with the header it wanted and the value it got, which\n * every runner reports as the test failure.\n */\n\nexport interface SecurityContractCookie {\n name: string\n value: string\n}\n\nexport interface SecurityContractTarget {\n /** The app's `proxy` export — the value `withSecurityHeaders` returned. */\n proxy: SecuredProxy\n /** The app's `config` export. Its matcher is checked too. */\n config: { matcher: readonly string[] }\n /**\n * Cookies that make a request look signed-in, so an auth module's proxy\n * passes it through instead of redirecting.\n *\n * Defaults to both QDC session cookies at once, which is what lets one\n * shipped test file cover every recipe: an app generated from `next-auth`\n * reads `qdc_session`, one from `next-betterauth` reads\n * `better-auth.session_token`, and a `next-base` app reads neither.\n */\n sessionCookies?: readonly SecurityContractCookie[]\n /** The URL the stub request carries. Must be a route the matcher covers. */\n url?: string\n}\n\nexport interface SecurityCheck {\n name: string\n run: () => Promise<void>\n}\n\nconst DEFAULT_SESSION_COOKIES: SecurityContractCookie[] = [\n { name: \"qdc_session\", value: \"test\" },\n { name: \"better-auth.session_token\", value: \"test\" },\n]\n\nconst DEFAULT_URL = \"https://app.example.test/dashboard\"\n\nfunction nextUrlStub(href: string): URL {\n return Object.assign(new URL(href), { clone: () => nextUrlStub(href) })\n}\n\n/**\n * Enough of a `NextRequest` for a proxy: the URL it can clone and the cookie\n * jar it reads. Casting through `unknown` keeps the stub honest about being one\n * — a partial `NextRequest` is exactly what this is.\n */\nfunction makeRequest(url: string, cookies: readonly SecurityContractCookie[]): NextRequestStub {\n return Object.assign(new Request(url), {\n nextUrl: nextUrlStub(url),\n cookies: {\n has: (name: string) => cookies.some((cookie) => cookie.name === name),\n get: (name: string) => cookies.find((cookie) => cookie.name === name),\n getAll: () => [...cookies],\n },\n }) as unknown as NextRequestStub\n}\n\ntype NextRequestStub = Parameters<SecuredProxy>[0]\n\n/** No runtime reads the fetch event, and jsdom has no `NextFetchEvent`. */\nconst NO_EVENT = {} as unknown as Parameters<SecuredProxy>[1]\n\nfunction cspOf(response: Response): string {\n return (\n response.headers.get(\"content-security-policy\") ??\n response.headers.get(\"content-security-policy-report-only\") ??\n \"\"\n )\n}\n\nfunction nonceOf(csp: string): string | undefined {\n return /'nonce-([^']+)'/.exec(csp)?.[1]\n}\n\nfunction expectHeader(response: Response, name: string, value: string): void {\n const actual = response.headers.get(name)\n if (actual !== value) {\n throw new Error(\n `${name}: expected ${JSON.stringify(value)}, got ${actual === null ? \"no header\" : JSON.stringify(actual)}`,\n )\n }\n}\n\nfunction expectContains(actual: string, needle: string, what: string): void {\n if (!actual.includes(needle)) {\n throw new Error(`${what}: expected it to contain ${JSON.stringify(needle)}, got ${JSON.stringify(actual)}`)\n }\n}\n\nexport function securityHeaderChecks(target: SecurityContractTarget): SecurityCheck[] {\n const url = target.url ?? DEFAULT_URL\n const signedIn = target.sessionCookies ?? DEFAULT_SESSION_COOKIES\n const run = (cookies: readonly SecurityContractCookie[]): Promise<Response> =>\n Promise.resolve(target.proxy(makeRequest(url, cookies), NO_EVENT))\n\n return [\n {\n name: \"sends the static headers on a signed-in request\",\n async run() {\n const response = await run(signedIn)\n expectHeader(response, \"x-content-type-options\", \"nosniff\")\n expectHeader(response, \"x-frame-options\", \"DENY\")\n expectHeader(response, \"referrer-policy\", \"strict-origin-when-cross-origin\")\n expectHeader(response, \"cross-origin-resource-policy\", \"same-origin\")\n expectContains(\n response.headers.get(\"strict-transport-security\") ?? \"\",\n \"max-age=\",\n \"strict-transport-security\",\n )\n expectContains(\n response.headers.get(\"permissions-policy\") ?? \"\",\n \"camera=()\",\n \"permissions-policy\",\n )\n },\n },\n {\n name: \"sends them on a request with no session too\",\n async run() {\n // Whatever this app does with an anonymous request — pass it through or\n // redirect it to a login — the response is still one the browser hardens.\n const response = await run([])\n expectHeader(response, \"x-content-type-options\", \"nosniff\")\n expectContains(cspOf(response), \"default-src 'self'\", \"content-security-policy\")\n },\n },\n {\n name: \"builds a CSP with a fresh nonce per response\",\n async run() {\n const first = cspOf(await run(signedIn))\n const second = cspOf(await run(signedIn))\n\n expectContains(first, \"'strict-dynamic'\", \"content-security-policy\")\n expectContains(first, \"frame-ancestors 'none'\", \"content-security-policy\")\n expectContains(first, \"object-src 'none'\", \"content-security-policy\")\n expectContains(first, \"report-uri /api/csp-report\", \"content-security-policy\")\n\n const nonce = nonceOf(first)\n if (!nonce) throw new Error(`content-security-policy carries no nonce: ${first}`)\n if (nonce === nonceOf(second)) {\n throw new Error(`two responses shared one nonce (${nonce}); a reused nonce protects nothing`)\n }\n },\n },\n {\n name: \"hands the nonce to the renderer on the forwarded request\",\n async run() {\n // A nonce only protects anything if the page carrying it is the page the\n // nonce was minted for. Next reads it off the request's CSP header.\n const response = await run(signedIn)\n const nonce = nonceOf(cspOf(response))\n if (!nonce) throw new Error(\"content-security-policy carries no nonce\")\n\n expectHeader(response, \"x-middleware-request-x-qdc-nonce\", nonce)\n expectContains(\n response.headers.get(\"x-middleware-request-content-security-policy\") ?? \"\",\n `'nonce-${nonce}'`,\n \"the forwarded request's content-security-policy\",\n )\n },\n },\n {\n name: \"matches every route that serves HTML\",\n run() {\n if (target.config.matcher.length === 0) {\n throw new Error(\"config.matcher is empty, so the proxy never runs\")\n }\n // Next extracts `config` statically, so the app writes this as a\n // literal rather than calling `proxyMatcher`. That makes the literal\n // the thing that can drift, and this the check that catches it: the\n // build output and the image optimizer are the only sanctioned holes,\n // and nonce-ing them would be pointless work on every asset request.\n for (const pattern of target.config.matcher) {\n for (const excluded of ALWAYS_EXCLUDED) {\n expectContains(pattern, excluded, \"config.matcher entry\")\n }\n }\n return Promise.resolve()\n },\n },\n ]\n}\n"],"mappings":";;;;;AAwDA,IAAM,0BAAoD;AAAA,EACxD,EAAE,MAAM,eAAe,OAAO,OAAO;AAAA,EACrC,EAAE,MAAM,6BAA6B,OAAO,OAAO;AACrD;AAEA,IAAM,cAAc;AAEpB,SAAS,YAAY,MAAmB;AACtC,SAAO,OAAO,OAAO,IAAI,IAAI,IAAI,GAAG,EAAE,OAAO,MAAM,YAAY,IAAI,EAAE,CAAC;AACxE;AAOA,SAAS,YAAY,KAAa,SAA6D;AAC7F,SAAO,OAAO,OAAO,IAAI,QAAQ,GAAG,GAAG;AAAA,IACrC,SAAS,YAAY,GAAG;AAAA,IACxB,SAAS;AAAA,MACP,KAAK,CAAC,SAAiB,QAAQ,KAAK,CAAC,WAAW,OAAO,SAAS,IAAI;AAAA,MACpE,KAAK,CAAC,SAAiB,QAAQ,KAAK,CAAC,WAAW,OAAO,SAAS,IAAI;AAAA,MACpE,QAAQ,MAAM,CAAC,GAAG,OAAO;AAAA,IAC3B;AAAA,EACF,CAAC;AACH;AAKA,IAAM,WAAW,CAAC;AAElB,SAAS,MAAM,UAA4B;AACzC,SACE,SAAS,QAAQ,IAAI,yBAAyB,KAC9C,SAAS,QAAQ,IAAI,qCAAqC,KAC1D;AAEJ;AAEA,SAAS,QAAQ,KAAiC;AAChD,SAAO,kBAAkB,KAAK,GAAG,IAAI,CAAC;AACxC;AAEA,SAAS,aAAa,UAAoB,MAAc,OAAqB;AAC3E,QAAM,SAAS,SA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} from \"../../security-core/proxy\"\nimport { QORE_CSP_REPORT_URI } from \"../../security-core/cspReport\"\nimport type { SecuredProxy } from \"./index\"\n\n/**\n * The security-header contract, as a list of checks an app runs against its own\n * proxy.\n *\n * These are not tests of `@quatronic/sdk` — this package has its own. They are\n * for the generated app, so that removing `withSecurityHeaders` from\n * `src/proxy.ts`, or matching so few routes that it stops running, fails that\n * app's build rather than being noticed in a penetration test.\n *\n * It returns checks rather than declaring them, so this module needs no test\n * runner of its own and works under whichever one the app uses:\n *\n * import { describe, it } from \"vitest\"\n * import { securityHeaderChecks } from \"@quatronic/sdk/next/security/testing\"\n * import { config, proxy } from \"@/proxy\"\n *\n * describe(\"security headers\", () => {\n * for (const check of securityHeaderChecks({ proxy, config })) it(check.name, check.run)\n * })\n *\n * A failing check throws with the header it wanted and the value it got, which\n * every runner reports as the test failure.\n */\n\nexport interface SecurityContractCookie {\n name: string\n value: string\n}\n\nexport interface SecurityContractTarget {\n /** The app's `proxy` export — the value `withSecurityHeaders` returned. */\n proxy: SecuredProxy\n /** The app's `config` export. Its matcher is checked too. */\n config: { matcher: readonly string[] }\n /**\n * Cookies that make a request look signed-in, so an auth module's proxy\n * passes it through instead of redirecting.\n *\n * Defaults to both QDC session cookies at once, which is what lets one\n * shipped test file cover every recipe: an app generated from `next-auth`\n * reads `qdc_session`, one from `next-betterauth` reads\n * `better-auth.session_token`, and a `next-base` app reads neither.\n */\n sessionCookies?: readonly SecurityContractCookie[]\n /** The URL the stub request carries. Must be a route the matcher covers. */\n url?: string\n}\n\nexport interface SecurityCheck {\n name: string\n run: () => Promise<void>\n}\n\nconst DEFAULT_SESSION_COOKIES: SecurityContractCookie[] = [\n { name: \"qdc_session\", value: \"test\" },\n { name: \"better-auth.session_token\", value: \"test\" },\n]\n\nconst DEFAULT_URL = \"https://app.example.test/dashboard\"\n\nfunction nextUrlStub(href: string): URL {\n return Object.assign(new URL(href), { clone: () => nextUrlStub(href) })\n}\n\n/**\n * Enough of a `NextRequest` for a proxy: the URL it can clone and the cookie\n * jar it reads. Casting through `unknown` keeps the stub honest about being one\n * — a partial `NextRequest` is exactly what this is.\n */\nfunction makeRequest(url: string, cookies: readonly SecurityContractCookie[]): NextRequestStub {\n return Object.assign(new Request(url), {\n nextUrl: nextUrlStub(url),\n cookies: {\n has: (name: string) => cookies.some((cookie) => cookie.name === name),\n get: (name: string) => cookies.find((cookie) => cookie.name === name),\n getAll: () => [...cookies],\n },\n }) as unknown as NextRequestStub\n}\n\ntype NextRequestStub = Parameters<SecuredProxy>[0]\n\n/** No runtime reads the fetch event, and jsdom has no `NextFetchEvent`. */\nconst NO_EVENT = {} as unknown as Parameters<SecuredProxy>[1]\n\nfunction cspOf(response: Response): string {\n return (\n response.headers.get(\"content-security-policy\") ??\n response.headers.get(\"content-security-policy-report-only\") ??\n \"\"\n )\n}\n\nfunction nonceOf(csp: string): string | undefined {\n return /'nonce-([^']+)'/.exec(csp)?.[1]\n}\n\nfunction expectHeader(response: Response, name: string, value: string): void {\n const actual = response.headers.get(name)\n if (actual !== value) {\n throw new Error(\n `${name}: expected ${JSON.stringify(value)}, got ${actual === null ? \"no header\" : JSON.stringify(actual)}`,\n )\n }\n}\n\nconst REPORT_URIS = [\"/api/csp-report\", QORE_CSP_REPORT_URI]\n\nfunction expectContains(actual: string, needle: string, what: string): void {\n if (!actual.includes(needle)) {\n throw new Error(`${what}: expected it to contain ${JSON.stringify(needle)}, got ${JSON.stringify(actual)}`)\n }\n}\n\nexport function securityHeaderChecks(target: SecurityContractTarget): SecurityCheck[] {\n const url = target.url ?? DEFAULT_URL\n const signedIn = target.sessionCookies ?? DEFAULT_SESSION_COOKIES\n const run = (cookies: readonly SecurityContractCookie[]): Promise<Response> =>\n Promise.resolve(target.proxy(makeRequest(url, cookies), NO_EVENT))\n\n return [\n {\n name: \"sends the static headers on a signed-in request\",\n async run() {\n const response = await run(signedIn)\n expectHeader(response, \"x-content-type-options\", \"nosniff\")\n expectHeader(response, \"x-frame-options\", \"DENY\")\n expectHeader(response, \"referrer-policy\", \"strict-origin-when-cross-origin\")\n expectHeader(response, \"cross-origin-resource-policy\", \"same-origin\")\n expectContains(\n response.headers.get(\"strict-transport-security\") ?? \"\",\n \"max-age=\",\n \"strict-transport-security\",\n )\n expectContains(\n response.headers.get(\"permissions-policy\") ?? \"\",\n \"camera=()\",\n \"permissions-policy\",\n )\n },\n },\n {\n name: \"sends them on a request with no session too\",\n async run() {\n // Whatever this app does with an anonymous request — pass it through or\n // redirect it to a login — the response is still one the browser hardens.\n const response = await run([])\n expectHeader(response, \"x-content-type-options\", \"nosniff\")\n expectContains(cspOf(response), \"default-src 'self'\", \"content-security-policy\")\n },\n },\n {\n name: \"builds a CSP with a fresh nonce per response\",\n async run() {\n const first = cspOf(await run(signedIn))\n const second = cspOf(await run(signedIn))\n\n expectContains(first, \"'strict-dynamic'\", \"content-security-policy\")\n expectContains(first, \"frame-ancestors 'none'\", \"content-security-policy\")\n expectContains(first, \"object-src 'none'\", \"content-security-policy\")\n // `withSecurityHeaders` reports to the app's own route, `qoreProxy` to the\n // platform's; either one collects the evidence.\n if (!REPORT_URIS.some((uri) => first.includes(`report-uri ${uri}`))) {\n throw new Error(\n `content-security-policy: expected a report-uri of ${REPORT_URIS.join(\" or \")}, got ${JSON.stringify(first)}`,\n )\n }\n\n const nonce = nonceOf(first)\n if (!nonce) throw new Error(`content-security-policy carries no nonce: ${first}`)\n if (nonce === nonceOf(second)) {\n throw new Error(`two responses shared one nonce (${nonce}); a reused nonce protects nothing`)\n }\n },\n },\n {\n name: \"hands the nonce to the renderer on the forwarded request\",\n async run() {\n // A nonce only protects anything if the page carrying it is the page the\n // nonce was minted for. Next reads it off the request's CSP header.\n const response = await run(signedIn)\n const nonce = nonceOf(cspOf(response))\n if (!nonce) throw new Error(\"content-security-policy carries no nonce\")\n\n expectHeader(response, \"x-middleware-request-x-qdc-nonce\", nonce)\n expectContains(\n response.headers.get(\"x-middleware-request-content-security-policy\") ?? \"\",\n `'nonce-${nonce}'`,\n \"the forwarded request's content-security-policy\",\n )\n },\n },\n {\n name: \"matches every route that serves HTML\",\n run() {\n if (target.config.matcher.length === 0) {\n throw new Error(\"config.matcher is empty, so the proxy never runs\")\n }\n // Next extracts `config` statically, so the app writes this as a\n // literal rather than calling `proxyMatcher`. That makes the literal\n // the thing that can drift, and this the check that catches it: the\n // build output and the image optimizer are the only sanctioned holes,\n // and nonce-ing them would be pointless work on every asset request.\n for (const pattern of target.config.matcher) {\n for (const excluded of ALWAYS_EXCLUDED) {\n expectContains(pattern, excluded, \"config.matcher entry\")\n }\n }\n return Promise.resolve()\n },\n },\n ]\n}\n"],"mappings":";;;;;;;;;AAyDA,IAAM,0BAAoD;AAAA,EACxD,EAAE,MAAM,eAAe,OAAO,OAAO;AAAA,EACrC,EAAE,MAAM,6BAA6B,OAAO,OAAO;AACrD;AAEA,IAAM,cAAc;AAEpB,SAAS,YAAY,MAAmB;AACtC,SAAO,OAAO,OAAO,IAAI,IAAI,IAAI,GAAG,EAAE,OAAO,MAAM,YAAY,IAAI,EAAE,CAAC;AACxE;AAOA,SAAS,YAAY,KAAa,SAA6D;AAC7F,SAAO,OAAO,OAAO,IAAI,QAAQ,GAAG,GAAG;AAAA,IACrC,SAAS,YAAY,GAAG;AAAA,IACxB,SAAS;AAAA,MACP,KAAK,CAAC,SAAiB,QAAQ,KAAK,CAAC,WAAW,OAAO,SAAS,IAAI;AAAA,MACpE,KAAK,CAAC,SAAiB,QAAQ,KAAK,CAAC,WAAW,OAAO,SAAS,IAAI;AAAA,MACpE,QAAQ,MAAM,CAAC,GAAG,OAAO;AAAA,IAC3B;AAAA,EACF,CAAC;AACH;AAKA,IAAM,WAAW,CAAC;AAElB,SAAS,MAAM,UAA4B;AACzC,SACE,SAAS,QAAQ,IAAI,yBAAyB,KAC9C,SAAS,QAAQ,IAAI,qCAAqC,KAC1D;AAEJ;AAEA,SAAS,QAAQ,KAAiC;AAChD,SAAO,kBAAkB,KAAK,GAAG,IAAI,CAAC;AACxC;AA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E;AAMA,mBAAW,WAAW,OAAO,OAAO,SAAS;AAC3C,qBAAW,YAAY,iBAAiB;AACtC,2BAAe,SAAS,UAAU,sBAAsB;AAAA,UAC1D;AAAA,QACF;AACA,eAAO,QAAQ,QAAQ;AAAA,MACzB;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -179,7 +179,9 @@ async function ensureAdminSeed(db: NodePgDatabase): Promise<void> {
179
179
  const password = process.env.ADMIN_PASSWORD
180
180
  if (!email && !password) return
181
181
  if (!email || !password || password.length < 8) {
182
- Sentry.logger.warn("admin seed skipped: ADMIN_EMAIL and ADMIN_PASSWORD (min 8 chars) must both be set")
182
+ Sentry.logger.warn(
183
+ "admin seed skipped: ADMIN_EMAIL and ADMIN_PASSWORD (min 8 chars) must both be set",
184
+ )
183
185
  return
184
186
  }
185
187
  const existing = await db.select().from(user).where(eq(user.email, email)).limit(1)
@@ -15,7 +15,7 @@
15
15
  // (`--jscodeshift <dir it is installed in>`), and only a migration whose
16
16
  // codemod parses code needs it; `parser = "text"` codemods get the raw text.
17
17
  import { createHash } from "node:crypto"
18
- import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs"
18
+ import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, writeFileSync } from "node:fs"
19
19
  import { createRequire } from "node:module"
20
20
  import { dirname, join, resolve } from "node:path"
21
21
  import { fileURLToPath, pathToFileURL } from "node:url"
@@ -299,9 +299,21 @@ function loadJscodeshift(dir) {
299
299
  }
300
300
  }
301
301
 
302
+ /** @param {string} argv1 */
303
+ function isEntry(argv1) {
304
+ try {
305
+ return realpathSync(argv1) === realpathSync(fileURLToPath(import.meta.url))
306
+ } catch {
307
+ return false
308
+ }
309
+ }
310
+
302
311
  // CLI: node run.mjs --app <dir> [--from <version>] [--to <version>]
303
312
  // [--only id,id] [--test-only] [--jscodeshift <dir>] [--report <file>]
304
- if (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]) {
313
+ // Compared as real paths: a pnpm app reaches this file through a node_modules
314
+ // symlink, and the documented `node node_modules/@quatronic/sdk/...` would
315
+ // otherwise skip the CLI and exit 0 having done nothing.
316
+ if (process.argv[1] && isEntry(process.argv[1])) {
305
317
  const arg = (/** @type {string} */ name) => {
306
318
  const i = process.argv.indexOf(name)
307
319
  return i > 0 ? process.argv[i + 1] : undefined
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quatronic/sdk",
3
- "version": "0.7.0-test.3603305",
3
+ "version": "0.7.0-test.581e6df",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "publishConfig": {